| ︙ | | |
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
|
const char *z;
for(i=0; (z = cgi_parameter_name(i))!=0; i++){
Th_Store(z, P(z));
}
}
/*
** Rebuild all tickets named in the _pending_ticket table.
**
** This routine is called just prior to commit after new
** out-of-sequence ticket changes have been added.
*/
static int ticket_rebuild_at_commit(void){
Stmt q;
db_multi_exec(
"DELETE FROM ticket WHERE tkt_uuid IN _pending_ticket"
);
db_prepare(&q, "SELECT uuid FROM _pending_ticket");
while( db_step(&q)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q, 0);
ticket_rebuild_entry(zUuid);
}
db_multi_exec(
"DELETE FROM _pending_ticket"
);
return 0;
}
/*
** Update an entry of the TICKET table according to the information
** in the control file given in p. Attempt to create the appropriate
** TICKET table entry if createFlag is true. If createFlag is false,
** that means we already know the entry exists and so we can save the
** work of trying to create it.
**
** Return TRUE if a new TICKET entry was created and FALSE if an
** existing entry was revised.
*/
int ticket_insert(const Manifest *p, int createFlag, int checkTime){
int ticket_insert(const Manifest *p, int createFlag, int rid){
Blob sql;
Stmt q;
int i;
const char *zSep;
int rc = 0;
getAllTicketFields();
|
| ︙ | | |
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
+
+
+
-
-
-
-
-
-
-
-
-
-
|
if( fieldId(zName)<0 ) continue;
blob_appendf(&sql,", %s=coalesce(%s,'') || %Q",
zName, zName, p->aField[i].zValue);
}else{
if( fieldId(zName)<0 ) continue;
blob_appendf(&sql,", %s=%Q", zName, p->aField[i].zValue);
}
if( rid>0 ){
wiki_extract_links(p->aField[i].zValue, rid, 1, p->rDate, i==0, 0);
}
}
blob_appendf(&sql, " WHERE tkt_uuid='%s' AND tkt_mtime<:mtime",
p->zTicketUuid);
db_prepare(&q, "%s", blob_str(&sql));
db_bind_double(&q, ":mtime", p->rDate);
db_step(&q);
db_finalize(&q);
if( checkTime && db_changes()==0 ){
static int isInit = 0;
if( !isInit ){
db_multi_exec("CREATE TEMP TABLE _pending_ticket(uuid TEXT UNIQUE)");
db_commit_hook(ticket_rebuild_at_commit, 1);
isInit = 1;
}
db_multi_exec("INSERT OR IGNORE INTO _pending_ticket "
"VALUES(%Q)", p->zTicketUuid);
}
blob_reset(&sql);
return rc;
}
/*
** Rebuild an entire entry in the TICKET table
*/
|
| ︙ | | |
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
-
+
|
"DELETE FROM ticket WHERE tkt_uuid=%Q", zTktUuid
);
db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid);
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
content_get(rid, &content);
manifest_parse(&manifest, &content);
ticket_insert(&manifest, createFlag, 0);
ticket_insert(&manifest, createFlag, rid);
manifest_ticket_event(rid, &manifest, createFlag, tagid);
manifest_clear(&manifest);
createFlag = 0;
}
db_finalize(&q);
}
|
| ︙ | | |
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
|
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
|
+
+
+
+
+
+
-
+
+
+
-
+
|
** Show the change history for a single ticket in timeline format.
*/
void tkttimeline_page(void){
Stmt q;
char *zTitle;
char *zSQL;
const char *zUuid;
char *zFullUuid;
int tagid;
char zGlobPattern[50];
login_check_credentials();
if( !g.okHistory || !g.okRdTkt ){ login_needed(); return; }
zUuid = PD("name","");
style_submenu_element("History", "History",
"%s/tkthistory/%s", g.zTop, zUuid);
style_submenu_element("Status", "Status",
"%s/info/%s", g.zTop, zUuid);
zTitle = mprintf("Timeline Of Ticket %h", zUuid);
style_header(zTitle);
free(zTitle);
sqlite3_snprintf(6, zGlobPattern, "%s", zUuid);
canonical16(zGlobPattern, strlen(zGlobPattern));
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",zUuid);
if( tagid==0 ){
@ No such ticket: %h(zUuid)
style_footer();
return;
}
zFullUuid = db_text(0, "SELECT substr(tagname, 5) FROM tag WHERE tagid=%d",
tagid);
zSQL = mprintf("%s AND event.objid IN "
" (SELECT rid FROM tagxref WHERE tagid=%d) "
" (SELECT rid FROM tagxref WHERE tagid=%d UNION"
" SELECT srcid FROM backlink WHERE target GLOB '%.4s*' "
"AND '%s' GLOB (target||'*')) "
"ORDER BY mtime DESC",
timeline_query_for_www(), tagid);
timeline_query_for_www(), tagid, zFullUuid, zFullUuid);
db_prepare(&q, zSQL);
free(zSQL);
www_print_timeline(&q, TIMELINE_ARTID, 0);
db_finalize(&q);
style_footer();
}
|
| ︙ | | |