Fossil SCM
On the "Recent Threads" page (/forum) show the number of messages and the duration of each thread.
Commit
a50dfe6fae55b58aa93982a92a037c734f70a5cdb84fd554a9329cb533ac2196
Parent
4c43f2cd43a0dcf…
1 file changed
+23
-10
+23
-10
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -932,26 +932,39 @@ | ||
| 932 | 932 | iOfst = 0; |
| 933 | 933 | @ <h1>Recent Threads</h1> |
| 934 | 934 | @ <div class='fileage'><table width="100%%"> |
| 935 | 935 | if( db_table_exists("repository","forumpost") ){ |
| 936 | 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 | |
| 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 | |
| 944 | 949 | ); |
| 945 | 950 | while( db_step(&q)==SQLITE_ROW ){ |
| 946 | 951 | 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); | |
| 949 | 956 | @ <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 | + } | |
| 951 | 963 | @ </tr> |
| 952 | 964 | fossil_free(zAge); |
| 965 | + fossil_free(zDuration); | |
| 953 | 966 | } |
| 954 | 967 | db_finalize(&q); |
| 955 | 968 | } |
| 956 | 969 | @ </table></div> |
| 957 | 970 | style_footer(); |
| 958 | 971 |
| --- 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 |