def __append_redmine_summary(self, allEntries): redmineEntries = TogglHelper.filter_valid_entries(allEntries) if len(redmineEntries) > 0: self.append("---") self.append("**Redmine summary**") redmineIssuesSums = {} for e in redmineEntries: if e.taskId not in redmineIssuesSums: redmineIssuesSums[e.taskId] = 0 redmineIssuesSums[e.taskId] += e.duration longestTasks = sorted(redmineIssuesSums, key=lambda id: -redmineIssuesSums[id])[:3] self.append("You spent most time on:") for id in longestTasks: self.append("- #{}: {} h".format( id, TogglEntry.secondsToHours(redmineIssuesSums[id]))) self.append("")
def appendEntries(self, allEntries): self.append("Found entries in toggl: **{}** (filtered: **{}**)".format( len(allEntries), len(TogglHelper.filter_valid_entries(allEntries)))) self.__append_summary(allEntries) self.append("") self.__append_redmine_summary(allEntries)