Fossil

Check-in [ce5af096]
Login

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

Overview
Comment:Add the experimental /repo_tabsize page. It does not work because it shows the sizes of tables in the checkout database in some cases. Work is needed on the underlying dbstat virtual table. We will address that in the future and come back to this branch afterwards.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | piechart-table-sizes
Files: files | file ages | folders
SHA1: ce5af0966e7965bf0df1df4d8bb124d227f13bfb
User & Date: drh 2015-05-07 01:56:24
Context
2015-05-07
14:50
Merge in the /repo_tabsize page. Update to a post-3.8.10 version of SQLite that support the dbstat virtual table on attached databases, necessary to get the /repo_tabsize to work. check-in: 04942b31 user: drh tags: piechart
01:56
Add the experimental /repo_tabsize page. It does not work because it shows the sizes of tables in the checkout database in some cases. Work is needed on the underlying dbstat virtual table. We will address that in the future and come back to this branch afterwards. Closed-Leaf check-in: ce5af096 user: drh tags: piechart-table-sizes
2015-05-06
23:29
Add logic for generating SVG pie-charts based on SQL query results. check-in: 6ebd853c user: drh tags: piechart
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/stat.c.

353
354
355
356
357
358
359

















































  while( db_step(&q)==SQLITE_ROW ){
    @ %h(db_column_text(&q, 0));
  }
  @ </pre>
  db_finalize(&q);
  style_footer();
}
























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
  while( db_step(&q)==SQLITE_ROW ){
    @ %h(db_column_text(&q, 0));
  }
  @ </pre>
  db_finalize(&q);
  style_footer();
}

/*
** WEBPAGE: repo_tabsize
**
** Show relative sizes of tables in the repository database.
*/
void repo_tabsize_page(void){
  Stmt q;
  login_check_credentials();
  int nPageTotal;
  int nPageSmall;
  int nPageFree;
  if( !g.perm.Admin ){ login_needed(0); return; }

  style_header("Repository Table Sizes");
  style_adunit_config(ADUNIT_RIGHT_OK);
  style_submenu_element("Stat", "Repository Stats", "stat");
  style_submenu_element("URLs", "URLs and Checkouts", "urllist");
  db_multi_exec(
    "CREATE VIRTUAL TABLE temp.dbx USING dbstat;"
    "CREATE TEMP TABLE trans(name TEXT PRIMARY KEY, tabname TEXT)WITHOUT ROWID;"
    "INSERT INTO trans(name,tabname)"       
    "   SELECT name, tbl_name FROM %s.sqlite_master;"
    "CREATE TEMP TABLE piechart(amt REAL, label TEXT);"
    "INSERT INTO piechart(amt,label)"
    "  SELECT count(*), "
    "    coalesce((SELECT tabname FROM trans WHERE trans.name=dbx.name),name)"
    "    FROM dbx"
    "   GROUP BY 2 ORDER BY 2;",
    db_name("repository")
  );
  nPageFree = db_int(0, "PRAGMA freelist_count");
  db_multi_exec(
    "INSERT INTO piechart(amt,label) VALUES(%d,'(freelist)')",
    nPageFree
  );
  nPageTotal = db_int(0, "SELECT sum(amt) FROM piechart");
  nPageSmall = db_int(0, "SELECT sum(amt) FROM piechart WHERE amt<%d",
                         nPageTotal/50);
  db_multi_exec(
    "DELETE FROM piechart WHERE amt<%d;"
    "INSERT INTO piechart(amt,label) VALUES(%d,'(other)')", 
    nPageTotal/50, nPageSmall
  );
  @ <center><svg width='800' height='600'>
  piechart_render(800,600);
  @ </svg>
  style_footer();
}