Check-in [2abb23dba8]
Not logged in

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

Overview
Comment:Use the new timediff() function of SQLite 3.43.0 to refactor the "Duration of Project" line on the /stat page to be "Project Age".
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2abb23dba8bdc5dba8bbc3cd99a12af622db7286c3cf6c6a1b85056b50e08aaf
User & Date: drh 2023-06-15 11:58:11.439
References
2023-06-16
08:15
Update auto.def to MINIMUM_SQLITE_VERSION 3.43.00 to match [2abb23dba8bdc5db]. check-in: cbd27f23a6 user: stephan tags: trunk
Context
2023-06-15
12:21
To avoid unnecessary clutter in the error log, do not write timeout message to the error log for timeouts that occur during web-page reply and that use less than one second of CPU time. check-in: af2f7d1749 user: drh tags: trunk
11:58
Use the new timediff() function of SQLite 3.43.0 to refactor the "Duration of Project" line on the /stat page to be "Project Age". check-in: 2abb23dba8 user: drh tags: trunk
11:26
Document the --errorlog command-line option to "fossil ui". check-in: 1e64c2c10b user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727

  fossil_printf_selfcheck();
  fossil_limit_memory(1);

  /* When updating the minimum SQLite version, change the number here,
  ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def.  Take
  ** care that both places agree! */
  if( sqlite3_libversion_number()<3038000
   || strncmp(sqlite3_sourceid(),"2022-01-12",10)<0
  ){
    fossil_panic("Unsuitable SQLite version %s, must be at least 3.38.0",
                 sqlite3_libversion());
  }

  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
  sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
  memset(&g, 0, sizeof(g));
  g.now = time(0);







|
|

|







710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727

  fossil_printf_selfcheck();
  fossil_limit_memory(1);

  /* When updating the minimum SQLite version, change the number here,
  ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def.  Take
  ** care that both places agree! */
  if( sqlite3_libversion_number()<3043000
   || strncmp(sqlite3_sourceid(),"2023-06-12",10)<0
  ){
    fossil_panic("Unsuitable SQLite version %s, must be at least 3.43.0",
                 sqlite3_libversion());
  }

  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
  sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
  memset(&g, 0, sizeof(g));
  g.now = time(0);
Changes to src/stat.c.
139
140
141
142
143
144
145


146
147
148
149
150
151
152
*/
void stat_page(void){
  i64 t, fsize;
  int n, m;
  int szMax, szAvg;
  int brief;
  const char *p;



  login_check_credentials();
  if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
  brief = P("brief")!=0;
  style_header("Repository Statistics");
  style_adunit_config(ADUNIT_RIGHT_OK);
  if( g.perm.Admin ){







>
>







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
*/
void stat_page(void){
  i64 t, fsize;
  int n, m;
  int szMax, szAvg;
  int brief;
  const char *p;
  char *z;
  int Y, M, D;

  login_check_credentials();
  if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
  brief = P("brief")!=0;
  style_header("Repository Statistics");
  style_adunit_config(ADUNIT_RIGHT_OK);
  if( g.perm.Admin ){
255
256
257
258
259
260
261
262
263

264
265





266
267
268
269
270
271
272
        int nThread = db_int(0, "SELECT count(*) FROM forumpost"
                                " WHERE froot=fpid");
        @ <tr><th>Number&nbsp;Of&nbsp;Forum&nbsp;Posts:</th>
        @ <td>%,d(n) on %d(nThread) threads</td></tr>
      }
    }
  }
  @ <tr><th>Duration&nbsp;Of&nbsp;Project:</th><td>
  n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"

                " + 0.99");
  @ %,d(n) days or approximately %.2f(n/365.2425) years.





  @ </td></tr>
  p = db_get("project-code", 0);
  if( p ){
    @ <tr><th>Project&nbsp;ID:</th>
    @     <td>%h(p) %h(db_get("project-name",""))</td></tr>
  }
  p = db_get("parent-project-code", 0);







|
|
>
|
|
>
>
>
>
>







257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
        int nThread = db_int(0, "SELECT count(*) FROM forumpost"
                                " WHERE froot=fpid");
        @ <tr><th>Number&nbsp;Of&nbsp;Forum&nbsp;Posts:</th>
        @ <td>%,d(n) on %d(nThread) threads</td></tr>
      }
    }
  }
  @ <tr><th>Project&nbsp;Age:</th><td>
  z = db_text(0, "SELECT timediff('now',(SELECT min(mtime) FROM event));");
  sscanf(z, "+%d-%d-%d", &Y, &M, &D);
  if( Y>0 ){
    @ %d(Y) years, \
  }
  if( M>0 ){
    @ %d(M) months, \
  }
  @ %d(D) days
  @ </td></tr>
  p = db_get("project-code", 0);
  if( p ){
    @ <tr><th>Project&nbsp;ID:</th>
    @     <td>%h(p) %h(db_get("project-name",""))</td></tr>
  }
  p = db_get("parent-project-code", 0);