Fossil SCM

Improvements to the /urllist page.

drh 2021-12-23 12:20 trunk
Commit 8017aab792dc376084849817403c038edbc1150e79fd812c32c4fa88b08d0d3d
1 file changed +26 -8
+26 -8
--- src/stat.c
+++ src/stat.c
@@ -502,10 +502,11 @@
502502
** Show ways in which this repository has been accessed
503503
*/
504504
void urllist_page(void){
505505
Stmt q;
506506
int cnt;
507
+ int total = 0;
507508
int showAll = P("all")!=0;
508509
int nOmitted;
509510
sqlite3_int64 iNow;
510511
char *zPriorRepo = 0;
511512
@@ -516,36 +517,44 @@
516517
style_header("URLs and Checkouts");
517518
style_adunit_config(ADUNIT_RIGHT_OK);
518519
style_submenu_element("Stat", "stat");
519520
style_submenu_element("Schema", "repo_schema");
520521
iNow = db_int64(0, "SELECT strftime('%%s','now')");
521
- @ <div class="section">URLs used to access this repository</div>
522
- @ <table border="0" width='100%%'>
522
+
523
+
523524
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime"
524525
" FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC");
525526
cnt = 0;
526527
nOmitted = 0;
527528
while( db_step(&q)==SQLITE_ROW ){
529
+ if( cnt==0 ){
530
+ @ <div class="section">URLs used to access this repository</div>
531
+ @ <table border="0" width='100%%'>
532
+ }
528533
if( !showAll && db_column_int64(&q,2)<(iNow - 3600*24*30) && cnt>8 ){
529534
nOmitted++;
530535
}else{
531536
@ <tr><td width='100%%'>%h(db_column_text(&q,0))</td>
532537
@ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
533538
}
534539
cnt++;
535540
}
536541
db_finalize(&q);
537
- if( cnt==0 ){
538
- @ <tr><td>(none)</td>
539
- }else if( nOmitted ){
542
+
543
+ if( nOmitted ){
540544
@ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a>
541545
}
542
- @ </table>
546
+ if( cnt ){
547
+ @ <tr><td>(none)</td>
548
+ total += cnt;
549
+ }
543550
if( P("urlonly") ){
544551
style_finish_page();
545552
return;
546553
}
554
+
555
+
547556
db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')"
548557
" FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC");
549558
cnt = 0;
550559
while( db_step(&q)==SQLITE_ROW ){
551560
const char *zPath = db_column_text(&q,0);
@@ -560,11 +569,13 @@
560569
}
561570
}
562571
db_finalize(&q);
563572
if( cnt ){
564573
@ </table>
574
+ total += cnt;
565575
}
576
+
566577
cnt = 0;
567578
db_prepare(&q,
568579
"SELECT substr(name,10), datetime(mtime,'unixepoch')"
569580
" FROM config WHERE name GLOB 'syncwith:*'"
570581
"UNION ALL "
@@ -571,11 +582,11 @@
571582
"SELECT substr(name,10), datetime(mtime,'unixepoch')"
572583
" FROM config WHERE name GLOB 'syncfrom:*'"
573584
"UNION ALL "
574585
"SELECT substr(name,9), datetime(mtime,'unixepoch')"
575586
" FROM config WHERE name GLOB 'gitpush:*'"
576
- "ORDER BY 2 DESC"
587
+ "GROUP BY 1 ORDER BY 2 DESC"
577588
);
578589
while( db_step(&q)==SQLITE_ROW ){
579590
const char *zURL = db_column_text(&q,0);
580591
UrlData x;
581592
if( cnt==0 ){
@@ -590,10 +601,11 @@
590601
url_unparse(&x);
591602
}
592603
db_finalize(&q);
593604
if( cnt ){
594605
@ </table>
606
+ total += cnt;
595607
}
596608
597609
cnt = 0;
598610
db_prepare(&q,
599611
"SELECT"
@@ -613,11 +625,11 @@
613625
if( zUrl==0 || zSrc==0 ) continue;
614626
if( cnt++==0 ){
615627
@ <div class="section">Links from other repositories</div>
616628
@ <table border='0' width='100%%'>
617629
}
618
- if( zPriorRepo==0 || strcmp(zUrl,zSrc)!=0 ){
630
+ if( zPriorRepo==0 || strcmp(zPriorRepo,zSrc)!=0 ){
619631
fossil_free(zPriorRepo);
620632
zPriorRepo = fossil_strdup(zSrc);
621633
@ <tr><td colspan="4">\
622634
@ From <a href='%T(zSrc)'>%h(zSrc)</a>...</td></tr>
623635
}
@@ -632,10 +644,16 @@
632644
}
633645
db_finalize(&q);
634646
fossil_free(zPriorRepo);
635647
if( cnt ){
636648
@ </table>
649
+ total += cnt;
650
+ }
651
+
652
+
653
+ if( total==0 ){
654
+ @ <p>No record of any URLs or checkouts</p>
637655
}
638656
style_finish_page();
639657
}
640658
641659
/*
642660
--- src/stat.c
+++ src/stat.c
@@ -502,10 +502,11 @@
502 ** Show ways in which this repository has been accessed
503 */
504 void urllist_page(void){
505 Stmt q;
506 int cnt;
 
507 int showAll = P("all")!=0;
508 int nOmitted;
509 sqlite3_int64 iNow;
510 char *zPriorRepo = 0;
511
@@ -516,36 +517,44 @@
516 style_header("URLs and Checkouts");
517 style_adunit_config(ADUNIT_RIGHT_OK);
518 style_submenu_element("Stat", "stat");
519 style_submenu_element("Schema", "repo_schema");
520 iNow = db_int64(0, "SELECT strftime('%%s','now')");
521 @ <div class="section">URLs used to access this repository</div>
522 @ <table border="0" width='100%%'>
523 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime"
524 " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC");
525 cnt = 0;
526 nOmitted = 0;
527 while( db_step(&q)==SQLITE_ROW ){
 
 
 
 
528 if( !showAll && db_column_int64(&q,2)<(iNow - 3600*24*30) && cnt>8 ){
529 nOmitted++;
530 }else{
531 @ <tr><td width='100%%'>%h(db_column_text(&q,0))</td>
532 @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
533 }
534 cnt++;
535 }
536 db_finalize(&q);
537 if( cnt==0 ){
538 @ <tr><td>(none)</td>
539 }else if( nOmitted ){
540 @ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a>
541 }
542 @ </table>
 
 
 
543 if( P("urlonly") ){
544 style_finish_page();
545 return;
546 }
 
 
547 db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')"
548 " FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC");
549 cnt = 0;
550 while( db_step(&q)==SQLITE_ROW ){
551 const char *zPath = db_column_text(&q,0);
@@ -560,11 +569,13 @@
560 }
561 }
562 db_finalize(&q);
563 if( cnt ){
564 @ </table>
 
565 }
 
566 cnt = 0;
567 db_prepare(&q,
568 "SELECT substr(name,10), datetime(mtime,'unixepoch')"
569 " FROM config WHERE name GLOB 'syncwith:*'"
570 "UNION ALL "
@@ -571,11 +582,11 @@
571 "SELECT substr(name,10), datetime(mtime,'unixepoch')"
572 " FROM config WHERE name GLOB 'syncfrom:*'"
573 "UNION ALL "
574 "SELECT substr(name,9), datetime(mtime,'unixepoch')"
575 " FROM config WHERE name GLOB 'gitpush:*'"
576 "ORDER BY 2 DESC"
577 );
578 while( db_step(&q)==SQLITE_ROW ){
579 const char *zURL = db_column_text(&q,0);
580 UrlData x;
581 if( cnt==0 ){
@@ -590,10 +601,11 @@
590 url_unparse(&x);
591 }
592 db_finalize(&q);
593 if( cnt ){
594 @ </table>
 
595 }
596
597 cnt = 0;
598 db_prepare(&q,
599 "SELECT"
@@ -613,11 +625,11 @@
613 if( zUrl==0 || zSrc==0 ) continue;
614 if( cnt++==0 ){
615 @ <div class="section">Links from other repositories</div>
616 @ <table border='0' width='100%%'>
617 }
618 if( zPriorRepo==0 || strcmp(zUrl,zSrc)!=0 ){
619 fossil_free(zPriorRepo);
620 zPriorRepo = fossil_strdup(zSrc);
621 @ <tr><td colspan="4">\
622 @ From <a href='%T(zSrc)'>%h(zSrc)</a>...</td></tr>
623 }
@@ -632,10 +644,16 @@
632 }
633 db_finalize(&q);
634 fossil_free(zPriorRepo);
635 if( cnt ){
636 @ </table>
 
 
 
 
 
 
637 }
638 style_finish_page();
639 }
640
641 /*
642
--- src/stat.c
+++ src/stat.c
@@ -502,10 +502,11 @@
502 ** Show ways in which this repository has been accessed
503 */
504 void urllist_page(void){
505 Stmt q;
506 int cnt;
507 int total = 0;
508 int showAll = P("all")!=0;
509 int nOmitted;
510 sqlite3_int64 iNow;
511 char *zPriorRepo = 0;
512
@@ -516,36 +517,44 @@
517 style_header("URLs and Checkouts");
518 style_adunit_config(ADUNIT_RIGHT_OK);
519 style_submenu_element("Stat", "stat");
520 style_submenu_element("Schema", "repo_schema");
521 iNow = db_int64(0, "SELECT strftime('%%s','now')");
522
523
524 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime"
525 " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC");
526 cnt = 0;
527 nOmitted = 0;
528 while( db_step(&q)==SQLITE_ROW ){
529 if( cnt==0 ){
530 @ <div class="section">URLs used to access this repository</div>
531 @ <table border="0" width='100%%'>
532 }
533 if( !showAll && db_column_int64(&q,2)<(iNow - 3600*24*30) && cnt>8 ){
534 nOmitted++;
535 }else{
536 @ <tr><td width='100%%'>%h(db_column_text(&q,0))</td>
537 @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
538 }
539 cnt++;
540 }
541 db_finalize(&q);
542
543 if( nOmitted ){
 
544 @ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a>
545 }
546 if( cnt ){
547 @ <tr><td>(none)</td>
548 total += cnt;
549 }
550 if( P("urlonly") ){
551 style_finish_page();
552 return;
553 }
554
555
556 db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')"
557 " FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC");
558 cnt = 0;
559 while( db_step(&q)==SQLITE_ROW ){
560 const char *zPath = db_column_text(&q,0);
@@ -560,11 +569,13 @@
569 }
570 }
571 db_finalize(&q);
572 if( cnt ){
573 @ </table>
574 total += cnt;
575 }
576
577 cnt = 0;
578 db_prepare(&q,
579 "SELECT substr(name,10), datetime(mtime,'unixepoch')"
580 " FROM config WHERE name GLOB 'syncwith:*'"
581 "UNION ALL "
@@ -571,11 +582,11 @@
582 "SELECT substr(name,10), datetime(mtime,'unixepoch')"
583 " FROM config WHERE name GLOB 'syncfrom:*'"
584 "UNION ALL "
585 "SELECT substr(name,9), datetime(mtime,'unixepoch')"
586 " FROM config WHERE name GLOB 'gitpush:*'"
587 "GROUP BY 1 ORDER BY 2 DESC"
588 );
589 while( db_step(&q)==SQLITE_ROW ){
590 const char *zURL = db_column_text(&q,0);
591 UrlData x;
592 if( cnt==0 ){
@@ -590,10 +601,11 @@
601 url_unparse(&x);
602 }
603 db_finalize(&q);
604 if( cnt ){
605 @ </table>
606 total += cnt;
607 }
608
609 cnt = 0;
610 db_prepare(&q,
611 "SELECT"
@@ -613,11 +625,11 @@
625 if( zUrl==0 || zSrc==0 ) continue;
626 if( cnt++==0 ){
627 @ <div class="section">Links from other repositories</div>
628 @ <table border='0' width='100%%'>
629 }
630 if( zPriorRepo==0 || strcmp(zPriorRepo,zSrc)!=0 ){
631 fossil_free(zPriorRepo);
632 zPriorRepo = fossil_strdup(zSrc);
633 @ <tr><td colspan="4">\
634 @ From <a href='%T(zSrc)'>%h(zSrc)</a>...</td></tr>
635 }
@@ -632,10 +644,16 @@
644 }
645 db_finalize(&q);
646 fossil_free(zPriorRepo);
647 if( cnt ){
648 @ </table>
649 total += cnt;
650 }
651
652
653 if( total==0 ){
654 @ <p>No record of any URLs or checkouts</p>
655 }
656 style_finish_page();
657 }
658
659 /*
660

Keyboard Shortcuts

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