Fossil SCM

Enhance the s= query parameter (search) on /timeline so that it also searches the forum post content if the vfx query parameter is present.

drh 2023-04-22 18:53 trunk
Commit ea688fa67fd020713363d1c9b1470628082654ffd5f2901a6be5615d84b89f5c
1 file changed +32 -3
+32 -3
--- src/timeline.c
+++ src/timeline.c
@@ -144,10 +144,28 @@
144144
db_bind_int(&q, "$rid", rid);
145145
res = db_step(&q)==SQLITE_ROW;
146146
db_reset(&q);
147147
return res;
148148
}
149
+
150
+/*
151
+** Return the text of the unformatted
152
+** forum post given by the RID in the argument.
153
+*/
154
+static void forum_post_content_function(
155
+ sqlite3_context *context,
156
+ int argc,
157
+ sqlite3_value **argv
158
+){
159
+ int rid = sqlite3_value_int(argv[0]);
160
+ Manifest *pPost = manifest_get(rid, CFTYPE_FORUM, 0);
161
+ if( pPost ){
162
+ sqlite3_result_text(context, pPost->zWiki, -1, SQLITE_TRANSIENT);
163
+ manifest_destroy(pPost);
164
+ }
165
+}
166
+
149167
150168
/*
151169
** Output a timeline in the web format given a query. The query
152170
** should return these columns:
153171
**
@@ -2562,13 +2580,24 @@
25622580
blob_append_sql(&cond, " AND (event.user=%Q OR event.euser=%Q)",
25632581
zUser, zUser);
25642582
zThisUser = zUser;
25652583
}
25662584
if( zSearch ){
2567
- blob_append_sql(&cond,
2568
- " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
2569
- zSearch, zSearch);
2585
+ if( tmFlags & TIMELINE_FORUMTXT ){
2586
+ sqlite3_create_function(g.db, "forum_post_content", 1, SQLITE_UTF8,
2587
+ 0, forum_post_content_function, 0, 0);
2588
+ blob_append_sql(&cond,
2589
+ " AND (event.comment LIKE '%%%q%%'"
2590
+ " OR event.brief LIKE '%%%q%%'"
2591
+ " OR (event.type=='f' AND"
2592
+ " forum_post_content(event.objid) LIKE '%%%q%%'))",
2593
+ zSearch, zSearch, zSearch);
2594
+ }else{
2595
+ blob_append_sql(&cond,
2596
+ " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
2597
+ zSearch, zSearch);
2598
+ }
25702599
}
25712600
rBefore = symbolic_name_to_mtime(zBefore, &zBefore);
25722601
rAfter = symbolic_name_to_mtime(zAfter, &zAfter);
25732602
rCirca = symbolic_name_to_mtime(zCirca, &zCirca);
25742603
blob_append_sql(&sql, "%s", blob_sql_text(&cond));
25752604
--- src/timeline.c
+++ src/timeline.c
@@ -144,10 +144,28 @@
144 db_bind_int(&q, "$rid", rid);
145 res = db_step(&q)==SQLITE_ROW;
146 db_reset(&q);
147 return res;
148 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
150 /*
151 ** Output a timeline in the web format given a query. The query
152 ** should return these columns:
153 **
@@ -2562,13 +2580,24 @@
2562 blob_append_sql(&cond, " AND (event.user=%Q OR event.euser=%Q)",
2563 zUser, zUser);
2564 zThisUser = zUser;
2565 }
2566 if( zSearch ){
2567 blob_append_sql(&cond,
2568 " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
2569 zSearch, zSearch);
 
 
 
 
 
 
 
 
 
 
 
2570 }
2571 rBefore = symbolic_name_to_mtime(zBefore, &zBefore);
2572 rAfter = symbolic_name_to_mtime(zAfter, &zAfter);
2573 rCirca = symbolic_name_to_mtime(zCirca, &zCirca);
2574 blob_append_sql(&sql, "%s", blob_sql_text(&cond));
2575
--- src/timeline.c
+++ src/timeline.c
@@ -144,10 +144,28 @@
144 db_bind_int(&q, "$rid", rid);
145 res = db_step(&q)==SQLITE_ROW;
146 db_reset(&q);
147 return res;
148 }
149
150 /*
151 ** Return the text of the unformatted
152 ** forum post given by the RID in the argument.
153 */
154 static void forum_post_content_function(
155 sqlite3_context *context,
156 int argc,
157 sqlite3_value **argv
158 ){
159 int rid = sqlite3_value_int(argv[0]);
160 Manifest *pPost = manifest_get(rid, CFTYPE_FORUM, 0);
161 if( pPost ){
162 sqlite3_result_text(context, pPost->zWiki, -1, SQLITE_TRANSIENT);
163 manifest_destroy(pPost);
164 }
165 }
166
167
168 /*
169 ** Output a timeline in the web format given a query. The query
170 ** should return these columns:
171 **
@@ -2562,13 +2580,24 @@
2580 blob_append_sql(&cond, " AND (event.user=%Q OR event.euser=%Q)",
2581 zUser, zUser);
2582 zThisUser = zUser;
2583 }
2584 if( zSearch ){
2585 if( tmFlags & TIMELINE_FORUMTXT ){
2586 sqlite3_create_function(g.db, "forum_post_content", 1, SQLITE_UTF8,
2587 0, forum_post_content_function, 0, 0);
2588 blob_append_sql(&cond,
2589 " AND (event.comment LIKE '%%%q%%'"
2590 " OR event.brief LIKE '%%%q%%'"
2591 " OR (event.type=='f' AND"
2592 " forum_post_content(event.objid) LIKE '%%%q%%'))",
2593 zSearch, zSearch, zSearch);
2594 }else{
2595 blob_append_sql(&cond,
2596 " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
2597 zSearch, zSearch);
2598 }
2599 }
2600 rBefore = symbolic_name_to_mtime(zBefore, &zBefore);
2601 rAfter = symbolic_name_to_mtime(zAfter, &zAfter);
2602 rCirca = symbolic_name_to_mtime(zCirca, &zCirca);
2603 blob_append_sql(&sql, "%s", blob_sql_text(&cond));
2604

Keyboard Shortcuts

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