Fossil SCM

On the /repo_stat1 page, provide an option to show the sqlite_stat1 data in a tabular format.

drh 2023-12-31 13:40 trunk
Commit 3c68f7d44549d58b6344a9b24c5eef86aa23a309b51baadc29fd4f1e7c68bc75
1 file changed +20 -3
+20 -3
--- src/stat.c
+++ src/stat.c
@@ -768,32 +768,49 @@
768768
** WEBPAGE: repo_stat1
769769
**
770770
** Show the sqlite_stat1 table for the repository schema
771771
*/
772772
void repo_stat1_page(void){
773
+ int bTabular;
773774
login_check_credentials();
774775
if( !g.perm.Admin ){ login_needed(0); return; }
776
+ bTabular = PB("tabular");
775777
776778
style_set_current_feature("stat");
777779
style_header("Repository STAT1 Table");
778780
style_adunit_config(ADUNIT_RIGHT_OK);
779781
style_submenu_element("Stat", "stat");
780782
style_submenu_element("Schema", "repo_schema");
783
+ style_submenu_checkbox("tabular", "Tabular", 0, 0);
781784
if( db_table_exists("repository","sqlite_stat1") ){
782785
Stmt q;
783786
db_prepare(&q,
784787
"SELECT tbl, idx, stat FROM repository.sqlite_stat1"
785788
" ORDER BY tbl, idx");
786
- @ <pre>
789
+ if( bTabular ){
790
+ @ <table border="1" cellpadding="0" cellspacing="0">
791
+ @ <tr><th>Table<th>Index<th>Stat
792
+ }else{
793
+ @ <pre>
794
+ }
787795
while( db_step(&q)==SQLITE_ROW ){
788796
const char *zTab = db_column_text(&q,0);
789797
const char *zIdx = db_column_text(&q,1);
790798
const char *zStat = db_column_text(&q,2);
791799
char *zUrl = href("%R/repo_schema?n=%t",zTab);
792
- @ INSERT INTO sqlite_stat1 VALUES('%z(zUrl)%h(zTab)</a>','%h(zIdx)','%h(zStat)');
800
+ if( bTabular ){
801
+ @ <tr><td>%z(zUrl)%h(zTab)</a><td>%h(zIdx)<td>%h(zStat)
802
+ }else{
803
+ @ INSERT INTO sqlite_stat1 \
804
+ @ VALUES('%z(zUrl)%h(zTab)</a>','%h(zIdx)','%h(zStat)');
805
+ }
793806
}
794
- @ </pre>
807
+ if( bTabular ){
808
+ @ </table>
809
+ }else{
810
+ @ </pre>
811
+ }
795812
db_finalize(&q);
796813
}
797814
style_finish_page();
798815
}
799816
800817
--- src/stat.c
+++ src/stat.c
@@ -768,32 +768,49 @@
768 ** WEBPAGE: repo_stat1
769 **
770 ** Show the sqlite_stat1 table for the repository schema
771 */
772 void repo_stat1_page(void){
 
773 login_check_credentials();
774 if( !g.perm.Admin ){ login_needed(0); return; }
 
775
776 style_set_current_feature("stat");
777 style_header("Repository STAT1 Table");
778 style_adunit_config(ADUNIT_RIGHT_OK);
779 style_submenu_element("Stat", "stat");
780 style_submenu_element("Schema", "repo_schema");
 
781 if( db_table_exists("repository","sqlite_stat1") ){
782 Stmt q;
783 db_prepare(&q,
784 "SELECT tbl, idx, stat FROM repository.sqlite_stat1"
785 " ORDER BY tbl, idx");
786 @ <pre>
 
 
 
 
 
787 while( db_step(&q)==SQLITE_ROW ){
788 const char *zTab = db_column_text(&q,0);
789 const char *zIdx = db_column_text(&q,1);
790 const char *zStat = db_column_text(&q,2);
791 char *zUrl = href("%R/repo_schema?n=%t",zTab);
792 @ INSERT INTO sqlite_stat1 VALUES('%z(zUrl)%h(zTab)</a>','%h(zIdx)','%h(zStat)');
 
 
 
 
 
793 }
794 @ </pre>
 
 
 
 
795 db_finalize(&q);
796 }
797 style_finish_page();
798 }
799
800
--- src/stat.c
+++ src/stat.c
@@ -768,32 +768,49 @@
768 ** WEBPAGE: repo_stat1
769 **
770 ** Show the sqlite_stat1 table for the repository schema
771 */
772 void repo_stat1_page(void){
773 int bTabular;
774 login_check_credentials();
775 if( !g.perm.Admin ){ login_needed(0); return; }
776 bTabular = PB("tabular");
777
778 style_set_current_feature("stat");
779 style_header("Repository STAT1 Table");
780 style_adunit_config(ADUNIT_RIGHT_OK);
781 style_submenu_element("Stat", "stat");
782 style_submenu_element("Schema", "repo_schema");
783 style_submenu_checkbox("tabular", "Tabular", 0, 0);
784 if( db_table_exists("repository","sqlite_stat1") ){
785 Stmt q;
786 db_prepare(&q,
787 "SELECT tbl, idx, stat FROM repository.sqlite_stat1"
788 " ORDER BY tbl, idx");
789 if( bTabular ){
790 @ <table border="1" cellpadding="0" cellspacing="0">
791 @ <tr><th>Table<th>Index<th>Stat
792 }else{
793 @ <pre>
794 }
795 while( db_step(&q)==SQLITE_ROW ){
796 const char *zTab = db_column_text(&q,0);
797 const char *zIdx = db_column_text(&q,1);
798 const char *zStat = db_column_text(&q,2);
799 char *zUrl = href("%R/repo_schema?n=%t",zTab);
800 if( bTabular ){
801 @ <tr><td>%z(zUrl)%h(zTab)</a><td>%h(zIdx)<td>%h(zStat)
802 }else{
803 @ INSERT INTO sqlite_stat1 \
804 @ VALUES('%z(zUrl)%h(zTab)</a>','%h(zIdx)','%h(zStat)');
805 }
806 }
807 if( bTabular ){
808 @ </table>
809 }else{
810 @ </pre>
811 }
812 db_finalize(&q);
813 }
814 style_finish_page();
815 }
816
817

Keyboard Shortcuts

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