Fossil

Check-in [b6aa2a23]
Login

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

Overview
Comment:Further enhance the test-rename-list to include a title with the number of renames and the number of associated check-ins.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:b6aa2a2370925b411920a711030b41a218babbf7be523f9353aa8726bdd84faa
User & Date: drh 2018-05-05 19:02:54
Context
2018-05-05
19:04
Change the title on the /test-rename-list page to use "file name changes". check-in: f99b8819 user: drh tags: trunk
19:02
Further enhance the test-rename-list to include a title with the number of renames and the number of associated check-ins. check-in: b6aa2a23 user: drh tags: trunk
17:47
Make the table generated by /test-rename-list sortable. check-in: 80ec9d53 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/path.c.

   545    545       g.argv += 2;
   546    546       g.argc -= 2;
   547    547     }
   548    548   }
   549    549   
   550    550   /* Query to extract all rename operations */
   551    551   static const char zRenameQuery[] =
          552  +@ CREATE TEMP TABLE renames AS
   552    553   @ SELECT
   553         -@     datetime(event.mtime),
          554  +@     datetime(event.mtime) AS date,
   554    555   @     F.name AS old_name,
   555    556   @     T.name AS new_name,
   556         -@     blob.uuid
          557  +@     blob.uuid AS checkin
   557    558   @   FROM mlink, filename F, filename T, event, blob
   558    559   @  WHERE coalesce(mlink.pfnid,0)!=0 AND mlink.pfnid!=mlink.fnid
   559    560   @    AND F.fnid=mlink.pfnid
   560    561   @    AND T.fnid=mlink.fnid
   561    562   @    AND event.objid=mlink.mid
   562    563   @    AND event.type='ci'
   563         -@    AND blob.rid=mlink.mid
   564         -@  ORDER BY 1 DESC, 2;
          564  +@    AND blob.rid=mlink.mid;
   565    565   ;
   566    566   
   567    567   /* Query to extract distinct rename operations */
   568    568   static const char zDistinctRenameQuery[] =
          569  +@ CREATE TEMP TABLE renames AS
   569    570   @ SELECT
   570         -@     min(datetime(event.mtime)),
          571  +@     min(datetime(event.mtime)) AS date,
   571    572   @     F.name AS old_name,
   572    573   @     T.name AS new_name,
   573         -@     blob.uuid
          574  +@     blob.uuid AS checkin
   574    575   @   FROM mlink, filename F, filename T, event, blob
   575    576   @  WHERE coalesce(mlink.pfnid,0)!=0 AND mlink.pfnid!=mlink.fnid
   576    577   @    AND F.fnid=mlink.pfnid
   577    578   @    AND T.fnid=mlink.fnid
   578    579   @    AND event.objid=mlink.mid
   579    580   @    AND event.type='ci'
   580    581   @    AND blob.rid=mlink.mid
   581         -@  GROUP BY 2, 3
   582         -@  ORDER BY 1 DESC, 2;
          582  +@  GROUP BY 2, 3;
   583    583   ;
   584    584   
   585    585   /*
   586    586   ** WEBPAGE: test-rename-list
   587    587   **
   588    588   ** Print a list of all file rename operations throughout history.
   589    589   ** This page is intended for for testing purposes only and may change
   590    590   ** or be discontinued without notice.
   591    591   */
   592    592   void test_rename_list_page(void){
   593    593     Stmt q;
          594  +  int nRename;
          595  +  int nCheckin;
   594    596   
   595    597     login_check_credentials();
   596    598     if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
   597    599     if( P("all")!=0 ){
   598    600       style_header("List Of All File Name Changes");
   599         -    db_prepare(&q, "%s", zRenameQuery/*safe-for-%s*/);
          601  +    db_multi_exec("%s", zRenameQuery/*safe-for-%s*/);
   600    602       style_submenu_element("Distinct", "%R/test-rename-list");
   601    603     }else{
   602    604       style_header("List Of Distinct File Name Changes");
   603         -    db_prepare(&q, "%s", zDistinctRenameQuery/*safe-for-%s*/);
          605  +    db_multi_exec("%s", zDistinctRenameQuery/*safe-for-%s*/);
   604    606       style_submenu_element("All", "%R/test-rename-list?all");
   605    607     }
          608  +  nRename = db_int(0, "SELECT count(*) FROM renames;");
          609  +  nCheckin = db_int(0, "SELECT count(DISTINCT checkin) FROM renames;");
          610  +  db_prepare(&q, "SELECT date, old_name, new_name, checkin FROM renames"
          611  +                 " ORDER BY date DESC, old_name ASC");
          612  +  @ <h1>%d(nRename) rename operations in %d(nCheckin) check-ins</h1>
   606    613     @ <table class='sortable' data-column-types='tttt' data-init-sort='1'\
   607    614     @  border="1" cellpadding="2" cellspacing="0">
   608    615     @ <thead><tr><th>Date &amp; Time</th>
   609    616     @ <th>Old Name</th>
   610    617     @ <th>New Name</th>
   611    618     @ <th>Check-in</th></tr></thead><tbody>
   612    619     while( db_step(&q)==SQLITE_ROW ){