Beispiel #1
0
 def fetch_done(self, projects):
     cr_done = collections.defaultdict(lambda: datetime.timedelta(0))
     for project in projects:
         ticket_crs = ticket_store.get_all_ticket_crs(project, self.request)
         sql = sa.text("""
                       SELECT ticket, hours
                         FROM time_entries
                        WHERE ticket IS NOT NULL
                              AND project_id = :project_id
                       """).params(project_id=project.id)
         for ticket_id, hours in DBSession.execute(sql):
             try:
                 cr_id = ticket_crs[ticket_id]
                 cr_done[cr_id] += hours
             except KeyError:
                 # likely a ticket with no CR
                 pass
     return cr_done