Ejemplo n.º 1
0
    def __init__(self):
        # timeframe for report
        end_date = datetime.datetime.now()
        start_date = end_date - settings.timeframe

        # create report
        report_builder = Toggl(settings.api_token)
        workspaces = report_builder.get_workspaces()

        reports = []

        for ws_name, ws_id in workspaces:
            if ws_name in settings.workspace2meta.keys():
                metaproject = settings.workspace2meta[ws_name]

                for record in report_builder.detailed_report(
                        ws_id, start_date, end_date):
                    # record duration is in milliseconds
                    # divide by 3600000 to convert to hours
                    reports.append({
                        'user':
                        record['user'],
                        'team':
                        ws_name,
                        'project':
                        metaproject,
                        'subproject':
                        record['project'],
                        # example of record['start']: 2015-05-29T16:07:20+03:00
                        'start':
                        record['start'][:19],
                        'duration':
                        round(float(record['dur']) / 3600000, 2)
                    })
        self.df = pd.DataFrame(reports)
        self.df['start'] = pd.to_datetime(self.df['start'])
        self.total_weeks = set(self.df.set_index('start').index.week)
        self.first_timestamp = self.df.min(axis=1)
        self.projects = list(
            self.df.set_index('project').index.get_level_values(0).unique())
        self.users = list(
            self.df.set_index('user').index.get_level_values(0).unique())
Ejemplo n.º 2
0
                           settings.end_date))

    # create report
    report_builder = Toggl(settings.api_token)
    workspaces = report_builder.get_workspaces()

    weeks = week_list(start_date, end_date)

    last_records = {}  # last_records[user] = last_record

    report_writer = csv.DictWriter(
        sys.stdout, ['user', 'team', 'project', 'start', 'duration'])
    report_writer.writeheader()

    for (monday, sunday) in weeks:
        if sunday > today:
            break

        for ws_name, ws_id in workspaces:
            for record in report_builder.detailed_report(ws_id, monday, sunday):
                # record duration is in milliseconds
                # divide by 3600000 to convert to hours
                report_writer.writerow({
                    'user': record['user'],
                    'team': ws_name,
                    'project': record['project'],
                    # example of record['start']: 2015-05-29T16:07:20+03:00
                    'start': record['start'][:19],
                    'duration': round(float(record['dur']) / 3600000, 2)
                })
Ejemplo n.º 3
0
    weeks = week_list(start_date, today)

    report_writer = csv.DictWriter(
        args.output, ['user', 'team', 'project', 'start', 'duration'])
    report_writer.writeheader()

    for (monday, sunday) in weeks:
        if sunday > today:
            break

        for ws_name, ws_id in workspaces:
            inactive_users = set() if args.all else \
                set(u['name'] for u in
                    toggl.get_workspace_users(ws_id, inactive=True))

            for record in toggl.detailed_report(ws_id, monday, sunday):
                # exclude inactive users
                if record['user'] in inactive_users:
                    continue

                # record duration is in milliseconds
                # divide by 3600000 to convert to hours
                report_writer.writerow({
                    'user':
                    record['user'],
                    'team':
                    ws_name,
                    'project':
                    record['project'],
                    # example of record['start']: 2015-05-29T16:07:20+03:00
                    'start':
Ejemplo n.º 4
0
    workspaces = report_builder.get_workspaces()

    weeks = week_list(start_date, end_date)

    last_records = {}  # last_records[user] = last_record

    report_writer = csv.DictWriter(
        sys.stdout, ['user', 'team', 'project', 'start', 'duration'])
    report_writer.writeheader()

    for (monday, sunday) in weeks:
        if sunday > today:
            break

        for ws_name, ws_id in workspaces:
            for record in report_builder.detailed_report(
                    ws_id, monday, sunday):
                # record duration is in milliseconds
                # divide by 3600000 to convert to hours
                report_writer.writerow({
                    'user':
                    record['user'],
                    'team':
                    ws_name,
                    'project':
                    record['project'],
                    # example of record['start']: 2015-05-29T16:07:20+03:00
                    'start':
                    record['start'][:19],
                    'duration':
                    round(float(record['dur']) / 3600000, 2)
                })