source: timetrackingplugin/trunk/docs/example-reports.txt

Last change on this file was 16110, checked in by lucid, 7 years ago

TimeTrackingPlugin: Update example reports for new DB schema.

File size: 9.6 KB
Line 
1== TimeTracking Project Overview $YEAR
2
3Description:
4{{{
5Legend:
6* **Estimated Hours**: Sum of the estimated (i.e. allocated) hours.
7* **Logged Hours**: Sum of logged (i.e. spent) hours.
8* **Difference: Estimated - Logged**: Difference between estimated hours and logged hours = Remaining hours.
9
10* **Estimated Bygone Hours**: Estimated hours proportional to current date in year.
11* **Difference: Logged - Bygone**: By how much are we over the proportional estimate?
12
13See also [report:24 Category Overview], [report:25 Estimate Details]
14}}}
15
16{{{#!sql
17
18SELECT
19  row.category AS __group__,
20  row.project AS Project,
21  row.estimated_hours AS "Estimated Hours",
22  row.logged_hours AS "Logged Hours",
23  row.estimated_hours - row.logged_hours  AS "Remaining Hours",
24
25  ROUND(row.estimated_hours * factors.bygone, 1)
26  AS "Estimated Bygone Hours",
27
28  ROUND(row.logged_hours - (row.estimated_hours * factors.bygone), 1)
29  AS "Difference: Logged - Bygone",
30
31  (CASE WHEN row.estimated_hours - row.logged_hours < 0 THEN 1 ELSE 0 END)
32  AS __color__
33FROM (
34  SELECT
35    t.category as category,
36    t.project as project,
37    SUM(e.estimated_hours) AS estimated_hours,
38    SUM(COALESCE(s.spent_hours, 0)) as logged_hours
39  FROM timetrackingtasks t
40  LEFT OUTER JOIN timetrackingestimates e ON t.id == e.task_id AND e.name == $ESTIMATE
41  LEFT OUTER JOIN (
42    SELECT
43      SUM(e.spent_hours) as spent_hours,
44      e.task_id as task_id
45    FROM timetrackinglogs e
46    GROUP BY e.task_id
47  ) s ON t.id == s.task_id
48  WHERE t.year == (CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END)
49  GROUP BY t.category, t.project
50) row, (
51  SELECT
52    (days.now - days.start) / (days.end - days.start) AS bygone
53  FROM (
54    SELECT
55      julianday((CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END) || '-01-01') AS start,
56      julianday((CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END) || '-12-31') AS end,
57      julianday('now') AS now
58    ) days
59) factors
60
61}}}
62
63== TimeTracking Users Overview $YEAR
64
65Description:
66{{{
67Per user hours
68}}}
69
70{{{#!sql
71
72SELECT
73  total.user AS "User",
74  total.hours AS "Total Logged Hours",
75  target.hours AS "Logged Target Hours",
76  $TARGET_HOURS - target.hours AS "Remaining Target Hours",
77  ($TARGET_HOURS - target.hours) / 8 AS "Remaining Target Days"
78FROM (
79  SELECT
80    l.user as user,
81    SUM(l.spent_hours) as hours
82  FROM timetrackinglogs l
83  JOIN timetrackingtasks t ON t.id == l.task_id
84  WHERE t.year == (CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END)
85  GROUP BY l.user
86) total
87JOIN (
88  SELECT
89    l.user as user,
90    SUM(l.spent_hours) as hours
91  FROM timetrackinglogs l
92  JOIN timetrackingtasks t ON t.id == l.task_id
93  WHERE t.year == (CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END)AND
94        t.category == $TARGET_CATEGORY
95  GROUP BY l.user
96) target ON total.user == target.user
97
98}}}
99
100== TimeTracking Missing Tasks
101
102Description:
103{{{
104Deleting time tracking tasks can lead to orphaned log entries.
105There should be no such entries.
106}}}
107
108{{{#!sql
109
110SELECT
111  e.user as "User",
112  e.task_id as "Deleted task id",
113  e.date as date,
114  e.comment as "Comment",
115  1 AS __color__
116FROM timetrackinglogs e
117LEFT OUTER JOIN timetrackingtasks t ON t.id == e.task_id
118WHERE t.id IS NULL
119
120}}}
121
122== TimeTracking Logged Hours != 8
123
124Description:
125{{{
126Each week day is supposed to be logged with 8 hours.
127}}}
128
129{{{#!sql
130
131SELECT
132  d.user as "User",
133  d.date as date,
134  d.spent_hours "Logged hours != 8",
135  1 AS __color__
136FROM (
137  SELECT
138    e.user as user,
139    e.date as date,
140    SUM(e.spent_hours) as spent_hours
141  FROM timetrackinglogs e
142  GROUP BY e.date, e.user
143) d
144WHERE d.spent_hours != 8
145
146}}}
147
148== TimeTracking Missing Logged Days
149
150Description:
151{{{
152Each week day is supposed to be logged by all users. Here are the dates that only some users logged:
153}}}
154
155{{{#!sql
156
157SELECT a.user as  __group__, b.date
158FROM (SELECT DISTINCT user FROM timetrackinglogs) a
159CROSS JOIN (SELECT DISTINCT date FROM timetrackinglogs) b
160WHERE NOT EXISTS (
161  SELECT NULL
162  FROM timetrackinglogs i
163  WHERE i.user = a.user AND i.date = b.date
164)
165
166}}}
167
168== TimeTracking Unplanned $YEAR
169
170Description:
171{{{
172Unplanned hours
173}}}
174
175{{{#!sql
176
177SELECT
178  row.label AS "Category",
179  row.total AS "Total",
180  row.planned AS "Planned",
181  row.total - row.planned AS "Unplanned"
182FROM (
183  SELECT
184      (CASE WHEN t.category == $TARGET_CATEGORY THEN $TARGET_CATEGORY
185                                                ELSE 'Other' END) AS label,
186
187      (CASE WHEN t.category == $TARGET_CATEGORY THEN $TARGET_CATEGORY_HOURS
188                                                ELSE ($TARGET_TOTAL_HOURS - $TARGET_CATEGORY_HOURS) END) AS total,
189
190      SUM(e.estimated_hours) AS planned
191  FROM timetrackingtasks t
192  LEFT OUTER JOIN timetrackingestimates e ON t.id == e.task_id AND e.name == $ESTIMATE
193  WHERE t.year == (CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END)
194  GROUP BY t.category == $TARGET_CATEGORY
195) row
196ORDER BY row.label DESC
197
198}}}
199
200== TimeTracking Category Overview $YEAR
201
202Description:
203{{{
204Legend:
205* **Estimated Hours**: Sum of the estimated (i.e. allocated) hours.
206* **Logged Hours**: Sum of logged (i.e. spent) hours.
207* **Difference: Estimated - Logged**: Difference between estimated hours and logged hours = Remaining hours.
208
209* **Estimated Bygone Hours**: Estimated hours proportional to current date in year.
210* **Difference: Logged - Bygone**: By how much are we over the proportional estimate?
211
212See also [report:17 Project Overview], [report:25 Estimate Details]
213}}}
214
215{{{#!sql
216
217SELECT
218  row.category AS Category,
219  row.estimated_hours AS "Estimated Hours",
220  row.logged_hours AS "Logged Hours",
221  row.estimated_hours - row.logged_hours  AS "Remaining Hours",
222
223  ROUND(row.estimated_hours * factors.bygone, 1)
224  AS "Estimated Bygone Hours",
225
226  ROUND(row.logged_hours - (row.estimated_hours * factors.bygone), 1)
227  AS "Difference: Logged - Bygone",
228
229  (CASE WHEN row.estimated_hours - row.logged_hours < 0 THEN 1 ELSE 0 END)
230  AS __color__
231FROM (
232  SELECT
233    t.category as category,
234    SUM(e.estimated_hours) AS estimated_hours,
235    SUM(COALESCE(s.spent_hours, 0)) as logged_hours
236  FROM timetrackingtasks t
237  LEFT OUTER JOIN timetrackingestimates e ON t.id == e.task_id AND e.name == $ESTIMATE
238  LEFT OUTER JOIN (
239    SELECT
240      SUM(e.spent_hours) as spent_hours,
241      e.task_id as task_id
242    FROM timetrackinglogs e
243    GROUP BY e.task_id
244  ) s ON t.id == s.task_id
245  WHERE t.year == (CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END)
246  GROUP BY t.category
247) row, (
248  SELECT
249    (days.now - days.start) / (days.end - days.start) AS bygone
250  FROM (
251    SELECT
252      julianday((CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END) || '-01-01') AS start,
253      julianday((CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END) || '-12-31') AS end,
254      julianday('now') AS now
255    ) days
256) factors
257
258}}}
259
260== TimeTracking Task Estimates $YEAR
261
262Description:
263{{{
264Legend:
265* **Estimated Hours**: Estimated (i.e. allocated) hours.
266* **Logged Hours**: Sum of logged (i.e. spent) hours.
267* **Difference: Estimated - Logged**: Difference between estimated hours and logged hours = Remaining hours.
268
269* **Estimated Bygone Hours**: Estimated hours proportional to current date in year.
270* **Difference: Logged - Bygone**: By how much are we over the proportional estimate?
271
272See also [report:17 Project Overview], [report:24 Category Overview]
273}}}
274
275{{{#!sql
276
277SELECT
278  row.category AS __group__,
279  row.project AS Project,
280  row.task AS Task,
281  row.estimated_hours AS "Estimated Hours",
282  row.logged_hours AS "Logged Hours",
283  row.estimated_hours - row.logged_hours  AS "Remaining Hours",
284
285  ROUND(row.estimated_hours * factors.bygone, 1)
286  AS "Estimated Bygone Hours",
287
288  ROUND(row.logged_hours - (row.estimated_hours * factors.bygone), 1)
289  AS "Difference: Logged - Bygone",
290
291  (CASE WHEN row.estimated_hours - row.logged_hours < 0 THEN 1 ELSE 0 END)
292  AS __color__
293FROM (
294  SELECT
295    t.category as category,
296    t.project as project,
297    t.name as task,
298    e.estimated_hours AS estimated_hours,
299    SUM(COALESCE(s.spent_hours, 0)) as logged_hours
300  FROM timetrackingtasks t
301  LEFT OUTER JOIN timetrackingestimates e ON t.id == e.task_id AND e.name == $ESTIMATE
302  LEFT OUTER JOIN (
303    SELECT
304      SUM(e.spent_hours) as spent_hours,
305      e.task_id as task_id
306    FROM timetrackinglogs e
307    GROUP BY e.task_id
308  ) s ON t.id == s.task_id
309  WHERE t.year == (CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END)
310  GROUP BY t.id
311  ORDER BY t.category, t.project
312) row, (
313  SELECT
314    (days.now - days.start) / (days.end - days.start) AS bygone
315  FROM (
316    SELECT
317      julianday((CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END) || '-01-01') AS start,
318      julianday((CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END) || '-12-31') AS end,
319      julianday('now') AS now
320    ) days
321) factors
322
323}}}
324
325== TimeTracking Vacations $YEAR
326
327Description:
328{{{
329Shows the number of days spent on vacation.
330}}}
331
332{{{#!sql
333
334SELECT
335    t.name as "Name",
336    sum(l.spent_hours)/8.0 as "Vacation days taken"
337FROM timetrackingtasks t
338INNER JOIN timetrackinglogs l ON t.id == l.task_id
339WHERE t.project == 'Vacations' AND t.year == (CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END)
340GROUP BY l.user
341
342}}}
343
344== TimeTracking Vacations $YEAR Details
345
346Description:
347{{{
348Shows the vacation entries
349}}}
350
351{{{#!sql
352
353SELECT l.user as __group__, t.name, l.date, l.spent_hours
354FROM timetrackingtasks t
355INNER JOIN timetrackinglogs l ON t.id == l.task_id
356WHERE t.project == 'Vacations' AND t.year == (CASE WHEN $YEAR == '' THEN '2016' ELSE $YEAR END)
357
358}}}
Note: See TracBrowser for help on using the repository browser.