Fossil SCM

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".

drh 2023-06-15 11:58 trunk
Commit 2abb23dba8bdc5dba8bbc3cd99a12af622db7286c3cf6c6a1b85056b50e08aaf
2 files changed +3 -3 +12 -4
+3 -3
--- src/main.c
+++ src/main.c
@@ -712,14 +712,14 @@
712712
fossil_limit_memory(1);
713713
714714
/* When updating the minimum SQLite version, change the number here,
715715
** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take
716716
** care that both places agree! */
717
- if( sqlite3_libversion_number()<3038000
718
- || strncmp(sqlite3_sourceid(),"2022-01-12",10)<0
717
+ if( sqlite3_libversion_number()<3043000
718
+ || strncmp(sqlite3_sourceid(),"2023-06-12",10)<0
719719
){
720
- fossil_panic("Unsuitable SQLite version %s, must be at least 3.38.0",
720
+ fossil_panic("Unsuitable SQLite version %s, must be at least 3.43.0",
721721
sqlite3_libversion());
722722
}
723723
724724
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
725725
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
726726
--- src/main.c
+++ src/main.c
@@ -712,14 +712,14 @@
712 fossil_limit_memory(1);
713
714 /* When updating the minimum SQLite version, change the number here,
715 ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take
716 ** care that both places agree! */
717 if( sqlite3_libversion_number()<3038000
718 || strncmp(sqlite3_sourceid(),"2022-01-12",10)<0
719 ){
720 fossil_panic("Unsuitable SQLite version %s, must be at least 3.38.0",
721 sqlite3_libversion());
722 }
723
724 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
725 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
726
--- src/main.c
+++ src/main.c
@@ -712,14 +712,14 @@
712 fossil_limit_memory(1);
713
714 /* When updating the minimum SQLite version, change the number here,
715 ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take
716 ** care that both places agree! */
717 if( sqlite3_libversion_number()<3043000
718 || strncmp(sqlite3_sourceid(),"2023-06-12",10)<0
719 ){
720 fossil_panic("Unsuitable SQLite version %s, must be at least 3.43.0",
721 sqlite3_libversion());
722 }
723
724 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
725 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
726
+12 -4
--- src/stat.c
+++ src/stat.c
@@ -141,10 +141,12 @@
141141
i64 t, fsize;
142142
int n, m;
143143
int szMax, szAvg;
144144
int brief;
145145
const char *p;
146
+ char *z;
147
+ int Y, M, D;
146148
147149
login_check_credentials();
148150
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
149151
brief = P("brief")!=0;
150152
style_header("Repository Statistics");
@@ -257,14 +259,20 @@
257259
@ <tr><th>Number&nbsp;Of&nbsp;Forum&nbsp;Posts:</th>
258260
@ <td>%,d(n) on %d(nThread) threads</td></tr>
259261
}
260262
}
261263
}
262
- @ <tr><th>Duration&nbsp;Of&nbsp;Project:</th><td>
263
- n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
264
- " + 0.99");
265
- @ %,d(n) days or approximately %.2f(n/365.2425) years.
264
+ @ <tr><th>Project&nbsp;Age:</th><td>
265
+ z = db_text(0, "SELECT timediff('now',(SELECT min(mtime) FROM event));");
266
+ sscanf(z, "+%d-%d-%d", &Y, &M, &D);
267
+ if( Y>0 ){
268
+ @ %d(Y) years, \
269
+ }
270
+ if( M>0 ){
271
+ @ %d(M) months, \
272
+ }
273
+ @ %d(D) days
266274
@ </td></tr>
267275
p = db_get("project-code", 0);
268276
if( p ){
269277
@ <tr><th>Project&nbsp;ID:</th>
270278
@ <td>%h(p) %h(db_get("project-name",""))</td></tr>
271279
--- src/stat.c
+++ src/stat.c
@@ -141,10 +141,12 @@
141 i64 t, fsize;
142 int n, m;
143 int szMax, szAvg;
144 int brief;
145 const char *p;
 
 
146
147 login_check_credentials();
148 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
149 brief = P("brief")!=0;
150 style_header("Repository Statistics");
@@ -257,14 +259,20 @@
257 @ <tr><th>Number&nbsp;Of&nbsp;Forum&nbsp;Posts:</th>
258 @ <td>%,d(n) on %d(nThread) threads</td></tr>
259 }
260 }
261 }
262 @ <tr><th>Duration&nbsp;Of&nbsp;Project:</th><td>
263 n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
264 " + 0.99");
265 @ %,d(n) days or approximately %.2f(n/365.2425) years.
 
 
 
 
 
 
266 @ </td></tr>
267 p = db_get("project-code", 0);
268 if( p ){
269 @ <tr><th>Project&nbsp;ID:</th>
270 @ <td>%h(p) %h(db_get("project-name",""))</td></tr>
271
--- src/stat.c
+++ src/stat.c
@@ -141,10 +141,12 @@
141 i64 t, fsize;
142 int n, m;
143 int szMax, szAvg;
144 int brief;
145 const char *p;
146 char *z;
147 int Y, M, D;
148
149 login_check_credentials();
150 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
151 brief = P("brief")!=0;
152 style_header("Repository Statistics");
@@ -257,14 +259,20 @@
259 @ <tr><th>Number&nbsp;Of&nbsp;Forum&nbsp;Posts:</th>
260 @ <td>%,d(n) on %d(nThread) threads</td></tr>
261 }
262 }
263 }
264 @ <tr><th>Project&nbsp;Age:</th><td>
265 z = db_text(0, "SELECT timediff('now',(SELECT min(mtime) FROM event));");
266 sscanf(z, "+%d-%d-%d", &Y, &M, &D);
267 if( Y>0 ){
268 @ %d(Y) years, \
269 }
270 if( M>0 ){
271 @ %d(M) months, \
272 }
273 @ %d(D) days
274 @ </td></tr>
275 p = db_get("project-code", 0);
276 if( p ){
277 @ <tr><th>Project&nbsp;ID:</th>
278 @ <td>%h(p) %h(db_get("project-name",""))</td></tr>
279

Keyboard Shortcuts

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