Fossil SCM

On the "Recent Threads" page (/forum) show the number of messages and the duration of each thread.

drh 2018-08-15 20:17 trunk
Commit a50dfe6fae55b58aa93982a92a037c734f70a5cdb84fd554a9329cb533ac2196
1 file changed +23 -10
+23 -10
--- src/forum.c
+++ src/forum.c
@@ -932,26 +932,39 @@
932932
iOfst = 0;
933933
@ <h1>Recent Threads</h1>
934934
@ <div class='fileage'><table width="100%%">
935935
if( db_table_exists("repository","forumpost") ){
936936
db_prepare(&q,
937
- "SELECT julianday('now') - max(fmtime),"
938
- " (SELECT uuid FROM blob WHERE rid=fpid),"
939
- " (SELECT substr(comment,instr(comment,':')+2)"
940
- " FROM event WHERE objid=fpid)"
941
- " FROM forumpost"
942
- " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d",
943
- iLimit, iOfst
937
+ "SELECT"
938
+ " julianday('now') - max(fmtime) AS a," /* 0 */
939
+ " max(fmtime) - min(fmtime) AS b," /* 1 */
940
+ " sum(fprev IS NULL) AS c," /* 2 */
941
+ " (SELECT substr(uuid,1,10) FROM blob WHERE rid=froot)," /* 3 */
942
+ " (SELECT substr(comment,instr(comment,':')+2)" /* 4 */
943
+ " FROM event WHERE objid=(SELECT fpid FROM forumpost AS y"
944
+ " WHERE y.froot=x.froot"
945
+ " ORDER BY fmtime DESC LIMIT 1))"
946
+ " FROM forumpost AS x"
947
+ " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d;",
948
+ iLimit, iOfst
944949
);
945950
while( db_step(&q)==SQLITE_ROW ){
946951
char *zAge = human_readable_age(db_column_double(&q,0));
947
- const char *zUuid = db_column_text(&q, 1);
948
- const char *zTitle = db_column_text(&q, 2);
952
+ char *zDuration = human_readable_age(db_column_double(&q,1));
953
+ int nMsg = db_column_int(&q, 2);
954
+ const char *zUuid = db_column_text(&q, 3);
955
+ const char *zTitle = db_column_text(&q, 4);
949956
@ <tr><td>%h(zAge) ago</td>
950
- @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a>
957
+ @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a></td>
958
+ if( nMsg<2 ){
959
+ @ <td>no replies</td>
960
+ }else{
961
+ @ <td>%d(nMsg) posts spanning %h(zDuration)</td>
962
+ }
951963
@ </tr>
952964
fossil_free(zAge);
965
+ fossil_free(zDuration);
953966
}
954967
db_finalize(&q);
955968
}
956969
@ </table></div>
957970
style_footer();
958971
--- src/forum.c
+++ src/forum.c
@@ -932,26 +932,39 @@
932 iOfst = 0;
933 @ <h1>Recent Threads</h1>
934 @ <div class='fileage'><table width="100%%">
935 if( db_table_exists("repository","forumpost") ){
936 db_prepare(&q,
937 "SELECT julianday('now') - max(fmtime),"
938 " (SELECT uuid FROM blob WHERE rid=fpid),"
939 " (SELECT substr(comment,instr(comment,':')+2)"
940 " FROM event WHERE objid=fpid)"
941 " FROM forumpost"
942 " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d",
943 iLimit, iOfst
 
 
 
 
 
944 );
945 while( db_step(&q)==SQLITE_ROW ){
946 char *zAge = human_readable_age(db_column_double(&q,0));
947 const char *zUuid = db_column_text(&q, 1);
948 const char *zTitle = db_column_text(&q, 2);
 
 
949 @ <tr><td>%h(zAge) ago</td>
950 @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a>
 
 
 
 
 
951 @ </tr>
952 fossil_free(zAge);
 
953 }
954 db_finalize(&q);
955 }
956 @ </table></div>
957 style_footer();
958
--- src/forum.c
+++ src/forum.c
@@ -932,26 +932,39 @@
932 iOfst = 0;
933 @ <h1>Recent Threads</h1>
934 @ <div class='fileage'><table width="100%%">
935 if( db_table_exists("repository","forumpost") ){
936 db_prepare(&q,
937 "SELECT"
938 " julianday('now') - max(fmtime) AS a," /* 0 */
939 " max(fmtime) - min(fmtime) AS b," /* 1 */
940 " sum(fprev IS NULL) AS c," /* 2 */
941 " (SELECT substr(uuid,1,10) FROM blob WHERE rid=froot)," /* 3 */
942 " (SELECT substr(comment,instr(comment,':')+2)" /* 4 */
943 " FROM event WHERE objid=(SELECT fpid FROM forumpost AS y"
944 " WHERE y.froot=x.froot"
945 " ORDER BY fmtime DESC LIMIT 1))"
946 " FROM forumpost AS x"
947 " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d;",
948 iLimit, iOfst
949 );
950 while( db_step(&q)==SQLITE_ROW ){
951 char *zAge = human_readable_age(db_column_double(&q,0));
952 char *zDuration = human_readable_age(db_column_double(&q,1));
953 int nMsg = db_column_int(&q, 2);
954 const char *zUuid = db_column_text(&q, 3);
955 const char *zTitle = db_column_text(&q, 4);
956 @ <tr><td>%h(zAge) ago</td>
957 @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a></td>
958 if( nMsg<2 ){
959 @ <td>no replies</td>
960 }else{
961 @ <td>%d(nMsg) posts spanning %h(zDuration)</td>
962 }
963 @ </tr>
964 fossil_free(zAge);
965 fossil_free(zDuration);
966 }
967 db_finalize(&q);
968 }
969 @ </table></div>
970 style_footer();
971

Keyboard Shortcuts

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