-
Notifications
You must be signed in to change notification settings - Fork 0
/
retro.js
30 lines (25 loc) · 1 KB
/
retro.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import TogglClient from 'toggl-api'
import Argv from 'minimist'
import { Report, Template } from './src'
import { TimeService, WeekdayService } from './src'
import Settings from './settings'
const argv = Argv(process.argv.slice(2))
const apiToken = Settings.token
const workspace_id = Settings.workspaceId
const since = argv.since || Settings.since
const until = argv.until || Settings.until
let toggl = new TogglClient({ apiToken })
let report = new Report(new TimeService(), new WeekdayService())
let template = new Template(since, until)
toggl.summaryReport({
user_agent: "nodejs_client",
grouping: "clients",
subgrouping: "projects",
workspace_id, since, until
}, (error, reports) => {
let summary = report.getSummaryData(reports.total_grand, since, until)
let clientsData = report.getClientData(reports.data, since, until)
let projectsData = report.getProjectsData(reports.data, since, until)
let markdown = template.generateMarkdown(summary, clientsData, projectsData)
console.log(markdown)
})