Fossil

Check-in Differences
Login

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

Difference From 6419592d65 To stats-with-date-boundaries

2017-06-07
15:55
Fix the "fossil sha3sum" command so that it accepts "-" to mean stdin. Clarify the algorithm used. check-in: 86fa03adb1 user: drh tags: trunk
15:41
Added help information to date boundaries on the /reports page Leaf check-in: bbd063bf28 user: rkeene tags: stats-with-date-boundaries
15:35
Added first attempt at improving the activity stats with date boundaries check-in: 4617afddf4 user: rkeene tags: stats-with-date-boundaries
2017-06-06
17:53
Bug fix in the sha3sum() routine. Also comment-out that routine since it is not used anyplace in the code. check-in: 6419592d65 user: drh tags: trunk
17:49
Do not double-prompt for HttpAuth passwords. check-in: f423b10f79 user: drh tags: trunk

Changes to src/statrep.c.

52
53
54
55
56
57
58





59
60


61
62



63
64
65
66
67
68
69
** abstraction level to simplify the implementation code for the
** various /reports pages.
**
** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
** filter it applies, or '*' if no filter is applied (i.e. if "all" is
** used).
*/





static int stats_report_init_view(){
  const char *zType = PD("type","*");  /* analog to /timeline?y=... */


  const char *zRealType = NULL;        /* normalized form of zType */
  int rc = 0;                          /* result code */



  assert( !statsReportType && "Must not be called more than once." );
  switch( (zType && *zType) ? *zType : 0 ){
    case 'c':
    case 'C':
      zRealType = "ci";
      rc = *zRealType;
      break;







>
>
>
>
>


>
>


>
>
>







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
** abstraction level to simplify the implementation code for the
** various /reports pages.
**
** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
** filter it applies, or '*' if no filter is applied (i.e. if "all" is
** used).
*/
/*
 * XXX: From timeline.c -- a header would be a better place...
 */
double symbolic_name_to_mtime(const char *);
#define ONE_SECOND (1.0/86400.0)
static int stats_report_init_view(){
  const char *zType = PD("type","*");  /* analog to /timeline?y=... */
  const char *zAfter = P("a");         /* analog to /timeline?a=... */
  const char *zBefore = P("b");        /* analog to /timeline?b=... */
  const char *zRealType = NULL;        /* normalized form of zType */
  int rc = 0;                          /* result code */
  double rBefore, rAfter;              /* Boundary times */
  Blob sql;

  assert( !statsReportType && "Must not be called more than once." );
  switch( (zType && *zType) ? *zType : 0 ){
    case 'c':
    case 'C':
      zRealType = "ci";
      rc = *zRealType;
      break;
87
88
89
90
91
92
93

94






95
96
97
98
99
100
101
102
103
104



















105
106
107
108
109
110
111
      zRealType = "w";
      rc = *zRealType;
      break;
    default:
      rc = '*';
      break;
  }

  assert(0 != rc);






  if(zRealType){
    statsReportTimelineYFlag = zRealType;
    db_multi_exec("CREATE TEMP VIEW v_reports AS "
                  "SELECT * FROM event WHERE type GLOB %Q",
                  zRealType);
  }else{
    statsReportTimelineYFlag = "a";
    db_multi_exec("CREATE TEMP VIEW v_reports AS "
                  "SELECT * FROM event");
  }



















  return statsReportType = rc;
}

/*
** Returns a string suitable (for a given value of suitable) for
** use in a label with the header of the /reports pages, dependent
** on the 'type' flag. See stats_report_init_view().







>

>
>
>
>
>
>


|




|
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
      zRealType = "w";
      rc = *zRealType;
      break;
    default:
      rc = '*';
      break;
  }

  assert(0 != rc);

  rBefore = symbolic_name_to_mtime(zBefore);
  rAfter = symbolic_name_to_mtime(zAfter);

  blob_zero(&sql);

  if(zRealType){
    statsReportTimelineYFlag = zRealType;
    blob_append_sql(&sql, "CREATE TEMP VIEW v_reports AS "
                  "SELECT * FROM event WHERE type GLOB %Q",
                  zRealType);
  }else{
    statsReportTimelineYFlag = "a";
    blob_append_sql(&sql, "CREATE TEMP VIEW v_reports AS "
                  "SELECT * FROM event WHERE 1");
  }

  if( rAfter>0.0 ){
    if( rBefore>0.0 ){
      blob_append_sql(&sql,
        " AND mtime>=%.17g AND mtime<=%.17g",
        rAfter-ONE_SECOND, rBefore+ONE_SECOND);
    }else{
      blob_append_sql(&sql,
        " AND mtime>=%.17g",
        rAfter-ONE_SECOND);
    }
  }else if( rBefore>0.0 ){
    blob_append_sql(&sql,
      " AND mtime<=%.17g",
      rBefore+ONE_SECOND);
  }

  db_multi_exec("%s", blob_sql_text(&sql));

  return statsReportType = rc;
}

/*
** Returns a string suitable (for a given value of suitable) for
** use in a label with the header of the /reports pages, dependent
** on the 'type' flag. See stats_report_init_view().
660
661
662
663
664
665
666


667
668
669
670
671
672
673
** Query Parameters:
**
**   view=REPORT_NAME  Valid values: bymonth, byyear, byuser
**   user=NAME         Restricts statistics to the given user
**   type=TYPE         Restricts the report to a specific event type:
**                     ci (check-in), w (wiki), t (ticket), g (tag)
**                     Defaulting to all event types.


**
** The view-specific query parameters include:
**
** view=byweek:
**
**   y=YYYY            The year to report (default is the server's
**                     current year).







>
>







696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
** Query Parameters:
**
**   view=REPORT_NAME  Valid values: bymonth, byyear, byuser
**   user=NAME         Restricts statistics to the given user
**   type=TYPE         Restricts the report to a specific event type:
**                     ci (check-in), w (wiki), t (ticket), g (tag)
**                     Defaulting to all event types.
**   a=TIMEORTAG       Limit report to after this event
**   b=TIMEORTAG       Limit report to before this event
**
** The view-specific query parameters include:
**
** view=byweek:
**
**   y=YYYY            The year to report (default is the server's
**                     current year).