Add more reports to timebot #184
Conversation
gnarf
commented
Feb 17, 2017
src/db/time_history.sql
Outdated
project.short_code, | ||
to_char(date_trunc('week', timesheet.day), 'YYYY-MM-DD') as week, | ||
extract(epoch from sum(timesheet.duration)) / 3600 as hours, | ||
string_agg(timesheet.notes, '; '::text) as notes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have to cast this to text here? just curious
src/db/time_history.sql
Outdated
@@ -0,0 +1,12 @@ | |||
SELECT | |||
project.short_code, | |||
to_char(date_trunc('week', timesheet.day), 'YYYY-MM-DD') as week, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you do date(timesheet.day)::text
?
`${Number(time).toFixed(2)}h`; | ||
|
||
// target - current is "positive" when current < target (which is a negative thing) | ||
const emoji = val => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is kinda gross but i get it :p
src/timebot/commands/weekly.js
Outdated
behind, | ||
ratio, | ||
}) => | ||
`\`${code}${' '.repeat(10 - code.length)} [${histogramByPercentage(10, ratio)}\`${emoji(behind)}\`${histogramByPercentage(5, ratio - 1)}] ${` ${Math.round(ratio * 100)}`.slice(-3)}% c:${duration(current)} t:${duration(target)} a:${duration(avg)}\`${emoji(target - avg)}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we lift this into a named function and call it?
behind, | ||
ratio, | ||
}) => { | ||
// use short variables to make the template be one line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 zillion times better!