Fossil

Check-in [cbbee17312]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Deal with the fact that the Fossil repository has a few null users. Instead of having them match everything, including nonexistent users, make them match nothing.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | andygoth-user-reports
Files: files | file ages | folders
SHA1: cbbee17312070895347430f81784e81d142441dd
User & Date: andygoth 2015-05-18 02:36:02.974
Context
2015-05-18
02:37
Make the (Remove User Flag) link work even if the "u" query parameter was used instead of "user". ... (check-in: a4655a1dab user: andygoth tags: andygoth-user-reports)
02:36
Deal with the fact that the Fossil repository has a few null users. Instead of having them match everything, including nonexistent users, make them match nothing. ... (check-in: cbbee17312 user: andygoth tags: andygoth-user-reports)
02:22
Permit filtering weekday and file reports by user. Also ensure the user parameter is preserved when changing types. Lots of general cleanup to make this possible. ... (check-in: 60018f9d8a user: andygoth tags: andygoth-user-reports)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/statrep.c.
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
  stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear",
               blob_str(&userFilter) );
  blob_reset(&userFilter);
  db_prepare(&query,
             "SELECT substr(date(mtime),1,%d) AS timeframe,"
             "       count(*) AS eventCount"
             "  FROM v_reports"
             " WHERE ifnull(user=%Q,1)"
             " GROUP BY timeframe"
             " ORDER BY timeframe DESC",
             includeMonth ? 7 : 4, zUserName);
  @ <h1>Timeline Events (%s(stats_report_label_for_type()))
  @ by year%s(includeMonth ? "/month" : "")
  if( zUserName ){
    @ for user %h(zUserName)







|







260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
  stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear",
               blob_str(&userFilter) );
  blob_reset(&userFilter);
  db_prepare(&query,
             "SELECT substr(date(mtime),1,%d) AS timeframe,"
             "       count(*) AS eventCount"
             "  FROM v_reports"
             " WHERE ifnull(coalesce(euser,user,'')=%Q,1)"
             " GROUP BY timeframe"
             " ORDER BY timeframe DESC",
             includeMonth ? 7 : 4, zUserName);
  @ <h1>Timeline Events (%s(stats_report_label_for_type()))
  @ by year%s(includeMonth ? "/month" : "")
  if( zUserName ){
    @ for user %h(zUserName)
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
  db_multi_exec(
    "CREATE TEMP TABLE statrep(filename, cnt);"
    "INSERT INTO statrep(filename, cnt)"
    "  SELECT filename.name, count(distinct mlink.mid)"
    "    FROM filename, mlink, event"
    "   WHERE filename.fnid=mlink.fnid"
    "     AND mlink.mid=event.objid"
    "     AND ifnull(ifnull(euser,user)=%Q,1)"
    "   GROUP BY 1", zUserName
  );
  db_prepare(&query,
    "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/"
  );
  mxEvent = db_int(1, "SELECT max(cnt) FROM statrep");
  @ <h1>Check-ins Per File







|







476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
  db_multi_exec(
    "CREATE TEMP TABLE statrep(filename, cnt);"
    "INSERT INTO statrep(filename, cnt)"
    "  SELECT filename.name, count(distinct mlink.mid)"
    "    FROM filename, mlink, event"
    "   WHERE filename.fnid=mlink.fnid"
    "     AND mlink.mid=event.objid"
    "     AND ifnull(coalesce(euser,user,'')=%Q,1)"
    "   GROUP BY 1", zUserName
  );
  db_prepare(&query,
    "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/"
  );
  mxEvent = db_int(1, "SELECT max(cnt) FROM statrep");
  @ <h1>Check-ins Per File
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
    blob_appendf(&userFilter, "user=%s", zUserName);
  }
  stats_report_event_types_menu("byweekday", blob_str(&userFilter));
  db_prepare(&query,
               "SELECT cast(mtime %% 7 AS INTEGER) dow,"
               "       COUNT(*) AS eventCount"
               "  FROM v_reports"
               " WHERE ifnull(ifnull(euser,user)=%Q,1)"
               " GROUP BY dow ORDER BY dow", zUserName);
  @ <h1>Timeline Events (%h(stats_report_label_for_type())) by Day of the Week
  if( zUserName ){
    @ for user %h(zUserName)
  }
  @ </h1>
  db_multi_exec(
    "CREATE TEMP TABLE piechart(amt,label);"
    "INSERT INTO piechart SELECT count(*), cast(mtime %% 7 AS INT) FROM v_reports"
                         " WHERE ifnull(ifnull(euser,user)=%Q,1)"
                         " GROUP BY 2 ORDER BY 2;"
    "UPDATE piechart SET label = CASE label WHEN 0 THEN 'Monday' WHEN 1 THEN 'Tuesday'"
    "  WHEN 2 THEN 'Wednesday' WHEN 3 THEN 'Thursday' WHEN 4 THEN 'Friday'"
    "  WHEN 5 THEN 'Saturday' ELSE 'Sunday' END;", zUserName
  );
  if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
    @ <center><svg width=700 height=400>







|









|







543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
    blob_appendf(&userFilter, "user=%s", zUserName);
  }
  stats_report_event_types_menu("byweekday", blob_str(&userFilter));
  db_prepare(&query,
               "SELECT cast(mtime %% 7 AS INTEGER) dow,"
               "       COUNT(*) AS eventCount"
               "  FROM v_reports"
               " WHERE ifnull(coalesce(euser,user,'')=%Q,1)"
               " GROUP BY dow ORDER BY dow", zUserName);
  @ <h1>Timeline Events (%h(stats_report_label_for_type())) by Day of the Week
  if( zUserName ){
    @ for user %h(zUserName)
  }
  @ </h1>
  db_multi_exec(
    "CREATE TEMP TABLE piechart(amt,label);"
    "INSERT INTO piechart SELECT count(*), cast(mtime %% 7 AS INT) FROM v_reports"
                         " WHERE ifnull(coalesce(euser,user,'')=%Q,1)"
                         " GROUP BY 2 ORDER BY 2;"
    "UPDATE piechart SET label = CASE label WHEN 0 THEN 'Monday' WHEN 1 THEN 'Tuesday'"
    "  WHEN 2 THEN 'Wednesday' WHEN 3 THEN 'Thursday' WHEN 4 THEN 'Friday'"
    "  WHEN 5 THEN 'Saturday' ELSE 'Sunday' END;", zUserName
  );
  if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
    @ <center><svg width=700 height=400>
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
                 zUserName);
  }
  stats_report_event_types_menu("byweek", blob_str(&urlParams));
  blob_reset(&urlParams);
  db_prepare(&qYears,
             "SELECT DISTINCT substr(date(mtime),1,4) AS y"
             "  FROM v_reports"
             " WHERE ifnull(ifnull(euser,user)=%Q,1)"
             " GROUP BY y ORDER BY y", zUserName);
  cgi_printf("Select year: ");
  while( SQLITE_ROW == db_step(&qYears) ){
    const char *zT = db_column_text(&qYears, 0);
    if( i++ ){
      cgi_printf(" ");
    }







|







634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
                 zUserName);
  }
  stats_report_event_types_menu("byweek", blob_str(&urlParams));
  blob_reset(&urlParams);
  db_prepare(&qYears,
             "SELECT DISTINCT substr(date(mtime),1,4) AS y"
             "  FROM v_reports"
             " WHERE ifnull(coalesce(euser,user,'')=%Q,1)"
             " GROUP BY y ORDER BY y", zUserName);
  cgi_printf("Select year: ");
  while( SQLITE_ROW == db_step(&qYears) ){
    const char *zT = db_column_text(&qYears, 0);
    if( i++ ){
      cgi_printf(" ");
    }
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
    int total = 0;
    db_prepare(&stWeek,
               "SELECT DISTINCT strftime('%%W',mtime) AS wk, "
               "       count(*) AS n "
               "  FROM v_reports "
               " WHERE %Q=substr(date(mtime),1,4) "
               "   AND mtime < current_timestamp "
               "   AND ifnull(ifnull(euser,user)=%Q,1)"
               " GROUP BY wk ORDER BY wk DESC", zYear, zUserName);
    @ <h1>Timeline events (%h(stats_report_label_for_type()))
    @ for the calendar weeks of %h(zYear)
    if( zUserName ){
      @  for user %h(zUserName)
    }
    @ </h1>







|







666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
    int total = 0;
    db_prepare(&stWeek,
               "SELECT DISTINCT strftime('%%W',mtime) AS wk, "
               "       count(*) AS n "
               "  FROM v_reports "
               " WHERE %Q=substr(date(mtime),1,4) "
               "   AND mtime < current_timestamp "
               "   AND ifnull(coalesce(euser,user,'')=%Q,1)"
               " GROUP BY wk ORDER BY wk DESC", zYear, zUserName);
    @ <h1>Timeline events (%h(stats_report_label_for_type()))
    @ for the calendar weeks of %h(zYear)
    if( zUserName ){
      @  for user %h(zUserName)
    }
    @ </h1>