Fossil SCM
On the /urllist page, stop the display of access URLs after at least 8 have been shown and the last access is more than 30 days ago. Except, show them all if the "all" query parameter is used.
Commit
9d7ef44fb6a373c38b60a4e1a6daef819c090ebdd866145e65b8b87ee2c827ad
Parent
5826ba37acff82b…
1 file changed
+19
-7
+19
-7
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -341,43 +341,55 @@ | ||
| 341 | 341 | ** Show ways in which this repository has been accessed |
| 342 | 342 | */ |
| 343 | 343 | void urllist_page(void){ |
| 344 | 344 | Stmt q; |
| 345 | 345 | int cnt; |
| 346 | + int showAll = P("all")!=0; | |
| 347 | + int nOmitted; | |
| 348 | + sqlite3_int64 iNow; | |
| 346 | 349 | char *zRemote; |
| 347 | 350 | login_check_credentials(); |
| 348 | 351 | if( !g.perm.Admin ){ login_needed(0); return; } |
| 349 | 352 | |
| 350 | 353 | style_header("URLs and Checkouts"); |
| 351 | 354 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 352 | 355 | style_submenu_element("Stat", "stat"); |
| 353 | 356 | style_submenu_element("Schema", "repo_schema"); |
| 357 | + iNow = db_int64(0, "SELECT strftime('%%s','now')"); | |
| 354 | 358 | @ <div class="section">URLs</div> |
| 355 | 359 | @ <table border="0" width='100%%'> |
| 356 | - db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')" | |
| 357 | - " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC"); | |
| 360 | + db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime" | |
| 361 | + " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC"); | |
| 358 | 362 | cnt = 0; |
| 363 | + nOmitted = 0; | |
| 359 | 364 | while( db_step(&q)==SQLITE_ROW ){ |
| 360 | - @ <tr><td width='100%%'>%h(db_column_text(&q,0))</td> | |
| 361 | - @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> | |
| 365 | + if( !showAll && db_column_int64(&q,2)<(iNow - 3600*24*30) && cnt>8 ){ | |
| 366 | + nOmitted++; | |
| 367 | + }else{ | |
| 368 | + @ <tr><td width='100%%'>%h(db_column_text(&q,0))</td> | |
| 369 | + @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> | |
| 370 | + } | |
| 362 | 371 | cnt++; |
| 363 | 372 | } |
| 364 | 373 | db_finalize(&q); |
| 365 | 374 | if( cnt==0 ){ |
| 366 | 375 | @ <tr><td>(none)</td> |
| 376 | + }else if( nOmitted ){ | |
| 377 | + @ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a> | |
| 367 | 378 | } |
| 368 | 379 | @ </table> |
| 369 | 380 | @ <div class="section">Checkouts</div> |
| 370 | 381 | @ <table border="0" width='100%%'> |
| 371 | 382 | db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')" |
| 372 | 383 | " FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC"); |
| 373 | 384 | cnt = 0; |
| 374 | 385 | while( db_step(&q)==SQLITE_ROW ){ |
| 375 | 386 | const char *zPath = db_column_text(&q,0); |
| 376 | - if( !vfile_top_of_checkout(zPath) ) continue; | |
| 377 | - @ <tr><td width='100%%'>%h(zPath)</td> | |
| 378 | - @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> | |
| 387 | + if( vfile_top_of_checkout(zPath) ){ | |
| 388 | + @ <tr><td width='100%%'>%h(zPath)</td> | |
| 389 | + @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> | |
| 390 | + } | |
| 379 | 391 | cnt++; |
| 380 | 392 | } |
| 381 | 393 | db_finalize(&q); |
| 382 | 394 | if( cnt==0 ){ |
| 383 | 395 | @ <tr><td>(none)</td> |
| 384 | 396 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -341,43 +341,55 @@ | |
| 341 | ** Show ways in which this repository has been accessed |
| 342 | */ |
| 343 | void urllist_page(void){ |
| 344 | Stmt q; |
| 345 | int cnt; |
| 346 | char *zRemote; |
| 347 | login_check_credentials(); |
| 348 | if( !g.perm.Admin ){ login_needed(0); return; } |
| 349 | |
| 350 | style_header("URLs and Checkouts"); |
| 351 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 352 | style_submenu_element("Stat", "stat"); |
| 353 | style_submenu_element("Schema", "repo_schema"); |
| 354 | @ <div class="section">URLs</div> |
| 355 | @ <table border="0" width='100%%'> |
| 356 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')" |
| 357 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC"); |
| 358 | cnt = 0; |
| 359 | while( db_step(&q)==SQLITE_ROW ){ |
| 360 | @ <tr><td width='100%%'>%h(db_column_text(&q,0))</td> |
| 361 | @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> |
| 362 | cnt++; |
| 363 | } |
| 364 | db_finalize(&q); |
| 365 | if( cnt==0 ){ |
| 366 | @ <tr><td>(none)</td> |
| 367 | } |
| 368 | @ </table> |
| 369 | @ <div class="section">Checkouts</div> |
| 370 | @ <table border="0" width='100%%'> |
| 371 | db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')" |
| 372 | " FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC"); |
| 373 | cnt = 0; |
| 374 | while( db_step(&q)==SQLITE_ROW ){ |
| 375 | const char *zPath = db_column_text(&q,0); |
| 376 | if( !vfile_top_of_checkout(zPath) ) continue; |
| 377 | @ <tr><td width='100%%'>%h(zPath)</td> |
| 378 | @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> |
| 379 | cnt++; |
| 380 | } |
| 381 | db_finalize(&q); |
| 382 | if( cnt==0 ){ |
| 383 | @ <tr><td>(none)</td> |
| 384 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -341,43 +341,55 @@ | |
| 341 | ** Show ways in which this repository has been accessed |
| 342 | */ |
| 343 | void urllist_page(void){ |
| 344 | Stmt q; |
| 345 | int cnt; |
| 346 | int showAll = P("all")!=0; |
| 347 | int nOmitted; |
| 348 | sqlite3_int64 iNow; |
| 349 | char *zRemote; |
| 350 | login_check_credentials(); |
| 351 | if( !g.perm.Admin ){ login_needed(0); return; } |
| 352 | |
| 353 | style_header("URLs and Checkouts"); |
| 354 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 355 | style_submenu_element("Stat", "stat"); |
| 356 | style_submenu_element("Schema", "repo_schema"); |
| 357 | iNow = db_int64(0, "SELECT strftime('%%s','now')"); |
| 358 | @ <div class="section">URLs</div> |
| 359 | @ <table border="0" width='100%%'> |
| 360 | db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime" |
| 361 | " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC"); |
| 362 | cnt = 0; |
| 363 | nOmitted = 0; |
| 364 | while( db_step(&q)==SQLITE_ROW ){ |
| 365 | if( !showAll && db_column_int64(&q,2)<(iNow - 3600*24*30) && cnt>8 ){ |
| 366 | nOmitted++; |
| 367 | }else{ |
| 368 | @ <tr><td width='100%%'>%h(db_column_text(&q,0))</td> |
| 369 | @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> |
| 370 | } |
| 371 | cnt++; |
| 372 | } |
| 373 | db_finalize(&q); |
| 374 | if( cnt==0 ){ |
| 375 | @ <tr><td>(none)</td> |
| 376 | }else if( nOmitted ){ |
| 377 | @ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a> |
| 378 | } |
| 379 | @ </table> |
| 380 | @ <div class="section">Checkouts</div> |
| 381 | @ <table border="0" width='100%%'> |
| 382 | db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')" |
| 383 | " FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC"); |
| 384 | cnt = 0; |
| 385 | while( db_step(&q)==SQLITE_ROW ){ |
| 386 | const char *zPath = db_column_text(&q,0); |
| 387 | if( vfile_top_of_checkout(zPath) ){ |
| 388 | @ <tr><td width='100%%'>%h(zPath)</td> |
| 389 | @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr> |
| 390 | } |
| 391 | cnt++; |
| 392 | } |
| 393 | db_finalize(&q); |
| 394 | if( cnt==0 ){ |
| 395 | @ <tr><td>(none)</td> |
| 396 |