Fossil SCM
Adjust the /timeline?y=f display so that it also shows tags associated with forum events.
Commit
8e48eab25f63fc4c662ea5aba4931dd8d726983ba6014d71f0eaba19f9bc94b5
Parent
f1bf008a04e03ba…
1 file changed
+38
-4
+38
-4
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1416,10 +1416,30 @@ | ||
| 1416 | 1416 | "SELECT mlink.mid FROM mlink, filename\n" |
| 1417 | 1417 | " WHERE mlink.fnid=filename.fnid\n" |
| 1418 | 1418 | " AND %s)", |
| 1419 | 1419 | glob_expr("filename.name", mprintf("\"%s\"", zChng))); |
| 1420 | 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 | + | |
| 1421 | 1441 | static void addFileGlobDescription( |
| 1422 | 1442 | const char *zChng, /* The filename GLOB list */ |
| 1423 | 1443 | Blob *pDescription /* Result description */ |
| 1424 | 1444 | ){ |
| 1425 | 1445 | if( zChng==0 ) return; |
| @@ -3072,10 +3092,15 @@ | ||
| 3072 | 3092 | blob_append_sql(&cond, |
| 3073 | 3093 | " AND event.type='t' AND event.comment GLOB 'New ticket*'"); |
| 3074 | 3094 | }else if( zType[0]=='h' ){ |
| 3075 | 3095 | blob_append_sql(&cond, |
| 3076 | 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))"); | |
| 3077 | 3102 | }else{ |
| 3078 | 3103 | blob_append_sql(&cond, " AND event.type=%Q", zType); |
| 3079 | 3104 | } |
| 3080 | 3105 | if( zType[0]=='c' ){ |
| 3081 | 3106 | zEType = "check-in"; |
| @@ -3088,22 +3113,31 @@ | ||
| 3088 | 3113 | }else if( zType[0]=='e' ){ |
| 3089 | 3114 | zEType = "technical note"; |
| 3090 | 3115 | }else if( zType[0]=='g' ){ |
| 3091 | 3116 | zEType = "tag"; |
| 3092 | 3117 | }else if( zType[0]=='f' ){ |
| 3093 | - zEType = "forum post"; | |
| 3118 | + zEType = "forum event"; | |
| 3094 | 3119 | }else if( zType[0]=='h' ){ |
| 3095 | 3120 | zEType = "new forum thread"; |
| 3096 | 3121 | tmFlags |= TIMELINE_NOPOST; |
| 3097 | 3122 | } |
| 3098 | 3123 | if( (zType[0]=='f' || zType[0]=='h') |
| 3099 | 3124 | && forum_status_match_setup(P("status")) |
| 3100 | 3125 | ){ |
| 3101 | 3126 | 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 | + } | |
| 3105 | 3139 | } |
| 3106 | 3140 | } |
| 3107 | 3141 | if( zUser ){ |
| 3108 | 3142 | int n = db_int(0,"SELECT count(*) FROM event" |
| 3109 | 3143 | " WHERE user=%Q OR euser=%Q", zUser, zUser); |
| 3110 | 3144 |
| --- 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 |