Fossil SCM

Remove some extraneous joins and apply a missing forum status filter rule. This seems to filter as desired.

stephan 2026-05-28 10:37 UTC forum-statuses
Commit ee392e1366cc05b6734b009cc0ea3d001803ce207b8d19c28fc771ce34d9e2ef
1 file changed +19 -16
+19 -16
--- src/forum.c
+++ src/forum.c
@@ -2499,54 +2499,57 @@
24992499
iStatusTagId, !!zStatusFilter, zStatusFilter
25002500
);
25012501
if( zStatusFilter ){
25022502
const int bIsDflt =
25032503
0==fossil_strcmp(pFstat->aStatus[0].zValue, zStatusFilter);
2504
- const int bIsKnown =bIsDflt
2505
- ? 1
2506
- : db_int(0, "SELECT 1 FROM forumstatus WHERE value=%Q",
2507
- zStatusFilter);
25082504
db_multi_exec(
2505
+ "WITH stati(val) AS (SELECT value FROM forumstatus)\n"
25092506
"INSERT INTO trootid\n"
25102507
/* Rules:
25112508
25122509
(1) Filter on status=$zStatusFilter
25132510
(2) If $zStatusFilter==default status then also include
25142511
any posts with no status tag.
2515
- (3) If no matching tag is found, assume a tag with the value
2516
- of the first (default) status.
2512
+ (3) If no status tag is found for a given post, assume a tag
2513
+ with the value of the first (default) status.
2514
+ (4) If a status value is found which is not in
2515
+ [forumstatus] then treat it as if it were the default
2516
+ value.
25172517
25182518
We need to ensure that we filter only the most recent
25192519
value of each tag and count tagtype=0 (cancel) tags
25202520
properly.
25212521
*/
2522
- " SELECT fpid FROM forumpost, event\n"
2523
- " LEFT JOIN tagxref x ON objid=rid\n"
2522
+ " SELECT fpid FROM forumpost\n"
2523
+ " LEFT JOIN tagxref x ON fpid=rid\n"
25242524
" WHERE froot=fpid AND firt IS NULL\n"
2525
+ " AND (x.tagtype IS NULL OR x.tagtype>0)\n"
25252526
" AND (x.tagid IS NULL OR x.tagid=%d)\n"
2526
- " AND fpid=objid AND type='f'\n"
25272527
" AND CASE\n"
2528
- " WHEN %d THEN (x.value IS NULL OR x.value=%Q)\n" /* (2,3) */
2528
+ " WHEN %d" /*bIsDflt*/
2529
+ " THEN ("
2530
+ " x.value IS NULL"
2531
+ " OR x.value=%Q"
2532
+ " OR x.value NOT IN stati" /* (4) */
2533
+ " )\n" /* (2,3,4) */
25292534
" ELSE x.value=%Q\n" /* (1) */
25302535
" END",
25312536
iStatusTagId, bIsDflt, zStatusFilter, zStatusFilter
25322537
);
25332538
(void)bIsDflt;
25342539
}else{
25352540
db_multi_exec(
25362541
"INSERT INTO trootid\n"
2537
- " SELECT fpid FROM forumpost, event\n"
2538
- " WHERE froot=fpid AND firt IS NULL\n"
2539
- " AND fpid=objid AND type='f'"
2542
+ " SELECT fpid FROM forumpost\n"
2543
+ " WHERE froot=fpid AND firt IS NULL"
25402544
);
25412545
}
25422546
}else{
25432547
db_multi_exec(
25442548
"INSERT INTO trootid\n"
2545
- " SELECT fpid FROM forumpost, event\n"
2546
- " WHERE froot=fpid AND firt IS NULL\n"
2547
- " AND fpid=objid AND type='f'"
2549
+ " SELECT fpid FROM forumpost\n"
2550
+ " WHERE froot=fpid AND firt IS NULL"
25482551
);
25492552
}
25502553
db_prepare(&q,
25512554
"WITH thread(root,endtime,lastrid) AS (\n"
25522555
" SELECT\n"
25532556
--- src/forum.c
+++ src/forum.c
@@ -2499,54 +2499,57 @@
2499 iStatusTagId, !!zStatusFilter, zStatusFilter
2500 );
2501 if( zStatusFilter ){
2502 const int bIsDflt =
2503 0==fossil_strcmp(pFstat->aStatus[0].zValue, zStatusFilter);
2504 const int bIsKnown =bIsDflt
2505 ? 1
2506 : db_int(0, "SELECT 1 FROM forumstatus WHERE value=%Q",
2507 zStatusFilter);
2508 db_multi_exec(
 
2509 "INSERT INTO trootid\n"
2510 /* Rules:
2511
2512 (1) Filter on status=$zStatusFilter
2513 (2) If $zStatusFilter==default status then also include
2514 any posts with no status tag.
2515 (3) If no matching tag is found, assume a tag with the value
2516 of the first (default) status.
 
 
 
2517
2518 We need to ensure that we filter only the most recent
2519 value of each tag and count tagtype=0 (cancel) tags
2520 properly.
2521 */
2522 " SELECT fpid FROM forumpost, event\n"
2523 " LEFT JOIN tagxref x ON objid=rid\n"
2524 " WHERE froot=fpid AND firt IS NULL\n"
 
2525 " AND (x.tagid IS NULL OR x.tagid=%d)\n"
2526 " AND fpid=objid AND type='f'\n"
2527 " AND CASE\n"
2528 " WHEN %d THEN (x.value IS NULL OR x.value=%Q)\n" /* (2,3) */
 
 
 
 
 
2529 " ELSE x.value=%Q\n" /* (1) */
2530 " END",
2531 iStatusTagId, bIsDflt, zStatusFilter, zStatusFilter
2532 );
2533 (void)bIsDflt;
2534 }else{
2535 db_multi_exec(
2536 "INSERT INTO trootid\n"
2537 " SELECT fpid FROM forumpost, event\n"
2538 " WHERE froot=fpid AND firt IS NULL\n"
2539 " AND fpid=objid AND type='f'"
2540 );
2541 }
2542 }else{
2543 db_multi_exec(
2544 "INSERT INTO trootid\n"
2545 " SELECT fpid FROM forumpost, event\n"
2546 " WHERE froot=fpid AND firt IS NULL\n"
2547 " AND fpid=objid AND type='f'"
2548 );
2549 }
2550 db_prepare(&q,
2551 "WITH thread(root,endtime,lastrid) AS (\n"
2552 " SELECT\n"
2553
--- src/forum.c
+++ src/forum.c
@@ -2499,54 +2499,57 @@
2499 iStatusTagId, !!zStatusFilter, zStatusFilter
2500 );
2501 if( zStatusFilter ){
2502 const int bIsDflt =
2503 0==fossil_strcmp(pFstat->aStatus[0].zValue, zStatusFilter);
 
 
 
 
2504 db_multi_exec(
2505 "WITH stati(val) AS (SELECT value FROM forumstatus)\n"
2506 "INSERT INTO trootid\n"
2507 /* Rules:
2508
2509 (1) Filter on status=$zStatusFilter
2510 (2) If $zStatusFilter==default status then also include
2511 any posts with no status tag.
2512 (3) If no status tag is found for a given post, assume a tag
2513 with the value of the first (default) status.
2514 (4) If a status value is found which is not in
2515 [forumstatus] then treat it as if it were the default
2516 value.
2517
2518 We need to ensure that we filter only the most recent
2519 value of each tag and count tagtype=0 (cancel) tags
2520 properly.
2521 */
2522 " SELECT fpid FROM forumpost\n"
2523 " LEFT JOIN tagxref x ON fpid=rid\n"
2524 " WHERE froot=fpid AND firt IS NULL\n"
2525 " AND (x.tagtype IS NULL OR x.tagtype>0)\n"
2526 " AND (x.tagid IS NULL OR x.tagid=%d)\n"
 
2527 " AND CASE\n"
2528 " WHEN %d" /*bIsDflt*/
2529 " THEN ("
2530 " x.value IS NULL"
2531 " OR x.value=%Q"
2532 " OR x.value NOT IN stati" /* (4) */
2533 " )\n" /* (2,3,4) */
2534 " ELSE x.value=%Q\n" /* (1) */
2535 " END",
2536 iStatusTagId, bIsDflt, zStatusFilter, zStatusFilter
2537 );
2538 (void)bIsDflt;
2539 }else{
2540 db_multi_exec(
2541 "INSERT INTO trootid\n"
2542 " SELECT fpid FROM forumpost\n"
2543 " WHERE froot=fpid AND firt IS NULL"
 
2544 );
2545 }
2546 }else{
2547 db_multi_exec(
2548 "INSERT INTO trootid\n"
2549 " SELECT fpid FROM forumpost\n"
2550 " WHERE froot=fpid AND firt IS NULL"
 
2551 );
2552 }
2553 db_prepare(&q,
2554 "WITH thread(root,endtime,lastrid) AS (\n"
2555 " SELECT\n"
2556

Keyboard Shortcuts

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