Fossil SCM

Use a VIEW rather than a TABLE for collecting the data for some piecharts.

drh 2016-01-20 18:31 trunk merge
Commit 2bd670ac3cfb1fbbabf857e093d5b945a284c9fe
1 file changed +18 -16
+18 -16
--- src/statrep.c
+++ src/statrep.c
@@ -334,12 +334,12 @@
334334
all rows. */
335335
stats_report_init_view();
336336
@ <h1>Timeline Events
337337
@ (%s(stats_report_label_for_type())) by User</h1>
338338
db_multi_exec(
339
- "CREATE TEMP TABLE piechart(amt,label);"
340
- "INSERT INTO piechart SELECT count(*), ifnull(euser,user) FROM v_reports"
339
+ "CREATE TEMP VIEW piechart(amt,label) AS"
340
+ " SELECT count(*), ifnull(euser,user) FROM v_reports"
341341
" GROUP BY ifnull(euser,user) ORDER BY count(*) DESC;"
342342
);
343343
if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
344344
@ <center><svg width=700 height=400>
345345
piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
@@ -482,24 +482,26 @@
482482
if( zUserName ){
483483
@ for user %h(zUserName)
484484
}
485485
@ </h1>
486486
db_multi_exec(
487
- "CREATE TEMP TABLE piechart(amt,label);"
488
- "INSERT INTO piechart"
489
- " SELECT count(*), cast(strftime('%%w', mtime) AS INT) FROM v_reports"
490
- " WHERE ifnull(coalesce(euser,user,'')=%Q,1)"
491
- " GROUP BY 2 ORDER BY 2;"
492
- "UPDATE piechart SET label = CASE label"
493
- " WHEN 0 THEN 'Sunday'"
494
- " WHEN 1 THEN 'Monday'"
495
- " WHEN 2 THEN 'Tuesday'"
496
- " WHEN 3 THEN 'Wednesday'"
497
- " WHEN 4 THEN 'Thursday'"
498
- " WHEN 5 THEN 'Friday'"
499
- " WHEN 6 THEN 'Saturday'"
500
- " ELSE 'ERROR' END;", zUserName
487
+ "CREATE TEMP VIEW piechart(amt,label) AS"
488
+ " SELECT count(*),"
489
+ " CASE cast(strftime('%%w', mtime) AS INT)"
490
+ " WHEN 0 THEN 'Sunday'"
491
+ " WHEN 1 THEN 'Monday'"
492
+ " WHEN 2 THEN 'Tuesday'"
493
+ " WHEN 3 THEN 'Wednesday'"
494
+ " WHEN 4 THEN 'Thursday'"
495
+ " WHEN 5 THEN 'Friday'"
496
+ " WHEN 6 THEN 'Saturday'"
497
+ " ELSE 'ERROR'"
498
+ " END"
499
+ " FROM v_reports"
500
+ " WHERE ifnull(coalesce(euser,user,'')=%Q,1)"
501
+ " GROUP BY 2 ORDER BY cast(strftime('%%w', mtime) AS INT);"
502
+ , zUserName
501503
);
502504
if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
503505
@ <center><svg width=700 height=400>
504506
piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
505507
@ </svg></centre><hr/>
506508
--- src/statrep.c
+++ src/statrep.c
@@ -334,12 +334,12 @@
334 all rows. */
335 stats_report_init_view();
336 @ <h1>Timeline Events
337 @ (%s(stats_report_label_for_type())) by User</h1>
338 db_multi_exec(
339 "CREATE TEMP TABLE piechart(amt,label);"
340 "INSERT INTO piechart SELECT count(*), ifnull(euser,user) FROM v_reports"
341 " GROUP BY ifnull(euser,user) ORDER BY count(*) DESC;"
342 );
343 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
344 @ <center><svg width=700 height=400>
345 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
@@ -482,24 +482,26 @@
482 if( zUserName ){
483 @ for user %h(zUserName)
484 }
485 @ </h1>
486 db_multi_exec(
487 "CREATE TEMP TABLE piechart(amt,label);"
488 "INSERT INTO piechart"
489 " SELECT count(*), cast(strftime('%%w', mtime) AS INT) FROM v_reports"
490 " WHERE ifnull(coalesce(euser,user,'')=%Q,1)"
491 " GROUP BY 2 ORDER BY 2;"
492 "UPDATE piechart SET label = CASE label"
493 " WHEN 0 THEN 'Sunday'"
494 " WHEN 1 THEN 'Monday'"
495 " WHEN 2 THEN 'Tuesday'"
496 " WHEN 3 THEN 'Wednesday'"
497 " WHEN 4 THEN 'Thursday'"
498 " WHEN 5 THEN 'Friday'"
499 " WHEN 6 THEN 'Saturday'"
500 " ELSE 'ERROR' END;", zUserName
 
 
501 );
502 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
503 @ <center><svg width=700 height=400>
504 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
505 @ </svg></centre><hr/>
506
--- src/statrep.c
+++ src/statrep.c
@@ -334,12 +334,12 @@
334 all rows. */
335 stats_report_init_view();
336 @ <h1>Timeline Events
337 @ (%s(stats_report_label_for_type())) by User</h1>
338 db_multi_exec(
339 "CREATE TEMP VIEW piechart(amt,label) AS"
340 " SELECT count(*), ifnull(euser,user) FROM v_reports"
341 " GROUP BY ifnull(euser,user) ORDER BY count(*) DESC;"
342 );
343 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
344 @ <center><svg width=700 height=400>
345 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
@@ -482,24 +482,26 @@
482 if( zUserName ){
483 @ for user %h(zUserName)
484 }
485 @ </h1>
486 db_multi_exec(
487 "CREATE TEMP VIEW piechart(amt,label) AS"
488 " SELECT count(*),"
489 " CASE cast(strftime('%%w', mtime) AS INT)"
490 " WHEN 0 THEN 'Sunday'"
491 " WHEN 1 THEN 'Monday'"
492 " WHEN 2 THEN 'Tuesday'"
493 " WHEN 3 THEN 'Wednesday'"
494 " WHEN 4 THEN 'Thursday'"
495 " WHEN 5 THEN 'Friday'"
496 " WHEN 6 THEN 'Saturday'"
497 " ELSE 'ERROR'"
498 " END"
499 " FROM v_reports"
500 " WHERE ifnull(coalesce(euser,user,'')=%Q,1)"
501 " GROUP BY 2 ORDER BY cast(strftime('%%w', mtime) AS INT);"
502 , zUserName
503 );
504 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
505 @ <center><svg width=700 height=400>
506 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
507 @ </svg></centre><hr/>
508

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button