def get(interval): from models import Dataset, Monkey, TimeInterval query_monkeys = Monkey.monkey_list(interval) efforts = {} for asn in Dataset.assignments: if asn.in_interval(interval): if asn.employee_name not in efforts: effort = Effort(Dataset.employees[asn.employee_name]) effort.totals = {monkey: 0 for monkey in query_monkeys} efforts[asn.employee_name] = effort effort = efforts[asn.employee_name] effort.assignments.append(asn) asn_interval = TimeInterval( first_month=asn.first_month, last_month=asn.last_month ) asn_monkeys = Monkey.monkey_list(asn_interval) for monkey in asn_monkeys: if monkey in query_monkeys: effort.totals[monkey] += asn.effort return query_monkeys, efforts
def _monkey_clicked(self, row, col): employee = self.tbl.item(row, 0).text() monkey = self.monkeys[col - 2] hdr = '%s\n%s' % (employee, Monkey.prettify(monkey)) lines = [] total = 0 for asn in self.efforts[employee].assignments: interval = TimeInterval( first_month=asn.first_month, last_month=asn.last_month ) asn_monkeys = Monkey.monkey_list(interval) if monkey in asn_monkeys: lines.append('%s: %d' % (asn.project_name, asn.effort)) total += asn.effort msg = hdr + '\n\n' + '\n'.join(lines) + ('\n\nTotal: %d' % total) QMessageBox.information(QMessageBox(), 'Effort Breakdown', msg)