Fossil SCM

Adjust the /timeline?y=f display so that it also shows tags associated with forum events.

drh 2026-10-24 20:09 UTC forum-tracking-enhancements
Commit 8e48eab25f63fc4c662ea5aba4931dd8d726983ba6014d71f0eaba19f9bc94b5
1 file changed +38 -4
+38 -4
--- src/timeline.c
+++ src/timeline.c
@@ -1416,10 +1416,30 @@
14161416
"SELECT mlink.mid FROM mlink, filename\n"
14171417
" WHERE mlink.fnid=filename.fnid\n"
14181418
" AND %s)",
14191419
glob_expr("filename.name", mprintf("\"%s\"", zChng)));
14201420
}
1421
+/*
1422
+** An SQL expression that is the FPID of the forum post that is tagged
1423
+** by the tag event (event.type='g') of the current row of the event
1424
+** table, or NULL if that tag event does not tag a forum post.
1425
+**
1426
+** The target is found from the first "Edit [HASH|" in the event.comment
1427
+** that manifest_crosslink() generates for each control artifact. HASH
1428
+** is at least 12 characters, so a range lookup on the first 12
1429
+** characters, which can use the index on blob.uuid, is used to find
1430
+** the tagged artifact. Only the first artifact tagged by each control
1431
+** artifact is considered.
1432
+*/
1433
+#define FORUM_TAG_TARGET_SQL \
1434
+ "(SELECT ftb.rid FROM blob AS ftb" \
1435
+ " WHERE instr(event.comment,'Edit [')>0" \
1436
+ " AND ftb.uuid>=substr(event.comment,instr(event.comment,'Edit [')+6,12)" \
1437
+ " AND ftb.uuid<substr(event.comment," \
1438
+ "instr(event.comment,'Edit [')+6,12)||'g'" \
1439
+ " AND EXISTS(SELECT 1 FROM forumpost WHERE fpid=ftb.rid))"
1440
+
14211441
static void addFileGlobDescription(
14221442
const char *zChng, /* The filename GLOB list */
14231443
Blob *pDescription /* Result description */
14241444
){
14251445
if( zChng==0 ) return;
@@ -3072,10 +3092,15 @@
30723092
blob_append_sql(&cond,
30733093
" AND event.type='t' AND event.comment GLOB 'New ticket*'");
30743094
}else if( zType[0]=='h' ){
30753095
blob_append_sql(&cond,
30763096
" AND event.type='f' AND event.comment GLOB 'Post:*'");
3097
+ }else if( zType[0]=='f' ){
3098
+ /* Forum posts plus tag events that tag forum posts */
3099
+ blob_append_sql(&cond,
3100
+ " AND (event.type='f' OR (event.type='g'"
3101
+ " AND " FORUM_TAG_TARGET_SQL " IS NOT NULL))");
30773102
}else{
30783103
blob_append_sql(&cond, " AND event.type=%Q", zType);
30793104
}
30803105
if( zType[0]=='c' ){
30813106
zEType = "check-in";
@@ -3088,22 +3113,31 @@
30883113
}else if( zType[0]=='e' ){
30893114
zEType = "technical note";
30903115
}else if( zType[0]=='g' ){
30913116
zEType = "tag";
30923117
}else if( zType[0]=='f' ){
3093
- zEType = "forum post";
3118
+ zEType = "forum event";
30943119
}else if( zType[0]=='h' ){
30953120
zEType = "new forum thread";
30963121
tmFlags |= TIMELINE_NOPOST;
30973122
}
30983123
if( (zType[0]=='f' || zType[0]=='h')
30993124
&& forum_status_match_setup(P("status"))
31003125
){
31013126
zStatus = P("status");
3102
- blob_append_sql(&cond,
3103
- " AND status_match((SELECT froot FROM forumpost"
3104
- " WHERE fpid=event.objid))");
3127
+ if( zType[0]=='f' ){
3128
+ /* A tag event matches the status of the thread it tags */
3129
+ blob_append_sql(&cond,
3130
+ " AND status_match((SELECT froot FROM forumpost"
3131
+ " WHERE fpid=CASE WHEN event.type='g'"
3132
+ " THEN " FORUM_TAG_TARGET_SQL
3133
+ " ELSE event.objid END))");
3134
+ }else{
3135
+ blob_append_sql(&cond,
3136
+ " AND status_match((SELECT froot FROM forumpost"
3137
+ " WHERE fpid=event.objid))");
3138
+ }
31053139
}
31063140
}
31073141
if( zUser ){
31083142
int n = db_int(0,"SELECT count(*) FROM event"
31093143
" WHERE user=%Q OR euser=%Q", zUser, zUser);
31103144
--- src/timeline.c
+++ src/timeline.c
@@ -1416,10 +1416,30 @@
1416 "SELECT mlink.mid FROM mlink, filename\n"
1417 " WHERE mlink.fnid=filename.fnid\n"
1418 " AND %s)",
1419 glob_expr("filename.name", mprintf("\"%s\"", zChng)));
1420 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1421 static void addFileGlobDescription(
1422 const char *zChng, /* The filename GLOB list */
1423 Blob *pDescription /* Result description */
1424 ){
1425 if( zChng==0 ) return;
@@ -3072,10 +3092,15 @@
3072 blob_append_sql(&cond,
3073 " AND event.type='t' AND event.comment GLOB 'New ticket*'");
3074 }else if( zType[0]=='h' ){
3075 blob_append_sql(&cond,
3076 " AND event.type='f' AND event.comment GLOB 'Post:*'");
 
 
 
 
 
3077 }else{
3078 blob_append_sql(&cond, " AND event.type=%Q", zType);
3079 }
3080 if( zType[0]=='c' ){
3081 zEType = "check-in";
@@ -3088,22 +3113,31 @@
3088 }else if( zType[0]=='e' ){
3089 zEType = "technical note";
3090 }else if( zType[0]=='g' ){
3091 zEType = "tag";
3092 }else if( zType[0]=='f' ){
3093 zEType = "forum post";
3094 }else if( zType[0]=='h' ){
3095 zEType = "new forum thread";
3096 tmFlags |= TIMELINE_NOPOST;
3097 }
3098 if( (zType[0]=='f' || zType[0]=='h')
3099 && forum_status_match_setup(P("status"))
3100 ){
3101 zStatus = P("status");
3102 blob_append_sql(&cond,
3103 " AND status_match((SELECT froot FROM forumpost"
3104 " WHERE fpid=event.objid))");
 
 
 
 
 
 
 
 
 
3105 }
3106 }
3107 if( zUser ){
3108 int n = db_int(0,"SELECT count(*) FROM event"
3109 " WHERE user=%Q OR euser=%Q", zUser, zUser);
3110
--- src/timeline.c
+++ src/timeline.c
@@ -1416,10 +1416,30 @@
1416 "SELECT mlink.mid FROM mlink, filename\n"
1417 " WHERE mlink.fnid=filename.fnid\n"
1418 " AND %s)",
1419 glob_expr("filename.name", mprintf("\"%s\"", zChng)));
1420 }
1421 /*
1422 ** An SQL expression that is the FPID of the forum post that is tagged
1423 ** by the tag event (event.type='g') of the current row of the event
1424 ** table, or NULL if that tag event does not tag a forum post.
1425 **
1426 ** The target is found from the first "Edit [HASH|" in the event.comment
1427 ** that manifest_crosslink() generates for each control artifact. HASH
1428 ** is at least 12 characters, so a range lookup on the first 12
1429 ** characters, which can use the index on blob.uuid, is used to find
1430 ** the tagged artifact. Only the first artifact tagged by each control
1431 ** artifact is considered.
1432 */
1433 #define FORUM_TAG_TARGET_SQL \
1434 "(SELECT ftb.rid FROM blob AS ftb" \
1435 " WHERE instr(event.comment,'Edit [')>0" \
1436 " AND ftb.uuid>=substr(event.comment,instr(event.comment,'Edit [')+6,12)" \
1437 " AND ftb.uuid<substr(event.comment," \
1438 "instr(event.comment,'Edit [')+6,12)||'g'" \
1439 " AND EXISTS(SELECT 1 FROM forumpost WHERE fpid=ftb.rid))"
1440
1441 static void addFileGlobDescription(
1442 const char *zChng, /* The filename GLOB list */
1443 Blob *pDescription /* Result description */
1444 ){
1445 if( zChng==0 ) return;
@@ -3072,10 +3092,15 @@
3092 blob_append_sql(&cond,
3093 " AND event.type='t' AND event.comment GLOB 'New ticket*'");
3094 }else if( zType[0]=='h' ){
3095 blob_append_sql(&cond,
3096 " AND event.type='f' AND event.comment GLOB 'Post:*'");
3097 }else if( zType[0]=='f' ){
3098 /* Forum posts plus tag events that tag forum posts */
3099 blob_append_sql(&cond,
3100 " AND (event.type='f' OR (event.type='g'"
3101 " AND " FORUM_TAG_TARGET_SQL " IS NOT NULL))");
3102 }else{
3103 blob_append_sql(&cond, " AND event.type=%Q", zType);
3104 }
3105 if( zType[0]=='c' ){
3106 zEType = "check-in";
@@ -3088,22 +3113,31 @@
3113 }else if( zType[0]=='e' ){
3114 zEType = "technical note";
3115 }else if( zType[0]=='g' ){
3116 zEType = "tag";
3117 }else if( zType[0]=='f' ){
3118 zEType = "forum event";
3119 }else if( zType[0]=='h' ){
3120 zEType = "new forum thread";
3121 tmFlags |= TIMELINE_NOPOST;
3122 }
3123 if( (zType[0]=='f' || zType[0]=='h')
3124 && forum_status_match_setup(P("status"))
3125 ){
3126 zStatus = P("status");
3127 if( zType[0]=='f' ){
3128 /* A tag event matches the status of the thread it tags */
3129 blob_append_sql(&cond,
3130 " AND status_match((SELECT froot FROM forumpost"
3131 " WHERE fpid=CASE WHEN event.type='g'"
3132 " THEN " FORUM_TAG_TARGET_SQL
3133 " ELSE event.objid END))");
3134 }else{
3135 blob_append_sql(&cond,
3136 " AND status_match((SELECT froot FROM forumpost"
3137 " WHERE fpid=event.objid))");
3138 }
3139 }
3140 }
3141 if( zUser ){
3142 int n = db_int(0,"SELECT count(*) FROM event"
3143 " WHERE user=%Q OR euser=%Q", zUser, zUser);
3144

Keyboard Shortcuts

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