Fossil SCM
Begin adding forum artifact parsing code.
Commit
a2b470f14cd42a053c413f91c65b7b45e5ffac937a0ca4800eb67d6f20625752
Parent
e893e9d01b8b217…
2 files changed
+12
+23
+12
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -2462,10 +2462,22 @@ | ||
| 2462 | 2462 | "REPLACE INTO event(type,mtime,objid,user,comment)" |
| 2463 | 2463 | "VALUES('g',%.17g,%d,%Q,%Q)", |
| 2464 | 2464 | p->rDate, rid, p->zUser, blob_str(&comment)+1 |
| 2465 | 2465 | ); |
| 2466 | 2466 | blob_reset(&comment); |
| 2467 | + } | |
| 2468 | + if( p->type==CFTYPE_FORUM ){ | |
| 2469 | + int froot, fprev, firt; | |
| 2470 | + schema_forum(); | |
| 2471 | + froot = uuid_to_rid(p->zThreadRoot, 1); | |
| 2472 | + fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0; | |
| 2473 | + firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0; | |
| 2474 | + db_multi_exec( | |
| 2475 | + "INSERT INTO forumpost(fpid,froot,fprev,firt,fmtime)" | |
| 2476 | + "VALUES(%d,%d,nullif(%d,0),nullif(%d,0),%.17g)", | |
| 2477 | + p->rid, froot, fprev, firt, p->rDate | |
| 2478 | + ); | |
| 2467 | 2479 | } |
| 2468 | 2480 | db_end_transaction(0); |
| 2469 | 2481 | if( permitHooks ){ |
| 2470 | 2482 | rc = xfer_run_common_script(); |
| 2471 | 2483 | if( rc==TH_OK ){ |
| 2472 | 2484 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2462,10 +2462,22 @@ | |
| 2462 | "REPLACE INTO event(type,mtime,objid,user,comment)" |
| 2463 | "VALUES('g',%.17g,%d,%Q,%Q)", |
| 2464 | p->rDate, rid, p->zUser, blob_str(&comment)+1 |
| 2465 | ); |
| 2466 | blob_reset(&comment); |
| 2467 | } |
| 2468 | db_end_transaction(0); |
| 2469 | if( permitHooks ){ |
| 2470 | rc = xfer_run_common_script(); |
| 2471 | if( rc==TH_OK ){ |
| 2472 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2462,10 +2462,22 @@ | |
| 2462 | "REPLACE INTO event(type,mtime,objid,user,comment)" |
| 2463 | "VALUES('g',%.17g,%d,%Q,%Q)", |
| 2464 | p->rDate, rid, p->zUser, blob_str(&comment)+1 |
| 2465 | ); |
| 2466 | blob_reset(&comment); |
| 2467 | } |
| 2468 | if( p->type==CFTYPE_FORUM ){ |
| 2469 | int froot, fprev, firt; |
| 2470 | schema_forum(); |
| 2471 | froot = uuid_to_rid(p->zThreadRoot, 1); |
| 2472 | fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0; |
| 2473 | firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0; |
| 2474 | db_multi_exec( |
| 2475 | "INSERT INTO forumpost(fpid,froot,fprev,firt,fmtime)" |
| 2476 | "VALUES(%d,%d,nullif(%d,0),nullif(%d,0),%.17g)", |
| 2477 | p->rid, froot, fprev, firt, p->rDate |
| 2478 | ); |
| 2479 | } |
| 2480 | db_end_transaction(0); |
| 2481 | if( permitHooks ){ |
| 2482 | rc = xfer_run_common_script(); |
| 2483 | if( rc==TH_OK ){ |
| 2484 |
+23
| --- src/schema.c | ||
| +++ src/schema.c | ||
| @@ -542,5 +542,28 @@ | ||
| 542 | 542 | @ |
| 543 | 543 | @ -- Identifier for this file type. |
| 544 | 544 | @ -- The integer is the same as 'FSLC'. |
| 545 | 545 | @ PRAGMA application_id=252006674; |
| 546 | 546 | ; |
| 547 | + | |
| 548 | +/* | |
| 549 | +** The following table holds information about forum posts. It | |
| 550 | +** is created on-demand whenever the manifest parser encounters | |
| 551 | +** a forum-post artifact. | |
| 552 | +*/ | |
| 553 | +static const char zForumSchema[] = | |
| 554 | +@ CREATE TABLE repository.forumpost( | |
| 555 | +@ fpid INTEGER PRIMARY KEY; -- BLOB.rid for the artifact | |
| 556 | +@ froot INT; -- fpid of the thread root | |
| 557 | +@ fprev INT; -- Previous version of this same post | |
| 558 | +@ firt INT; -- This post is in-reply-to | |
| 559 | +@ fmtime REAL; -- When posted. Julian day | |
| 560 | +@ ); | |
| 561 | +@ CREATE INDEX repository.forumthread ON forumpost(froot); | |
| 562 | +; | |
| 563 | + | |
| 564 | +/* Create the forum-post schema if it does not already exist */ | |
| 565 | +void schema_forum(void){ | |
| 566 | + if( !db_table_exists("repository","forumpost") ){ | |
| 567 | + db_multi_exec("%s",zForumSchema/*safe-for-%s*/); | |
| 568 | + } | |
| 569 | +} | |
| 547 | 570 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -542,5 +542,28 @@ | |
| 542 | @ |
| 543 | @ -- Identifier for this file type. |
| 544 | @ -- The integer is the same as 'FSLC'. |
| 545 | @ PRAGMA application_id=252006674; |
| 546 | ; |
| 547 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -542,5 +542,28 @@ | |
| 542 | @ |
| 543 | @ -- Identifier for this file type. |
| 544 | @ -- The integer is the same as 'FSLC'. |
| 545 | @ PRAGMA application_id=252006674; |
| 546 | ; |
| 547 | |
| 548 | /* |
| 549 | ** The following table holds information about forum posts. It |
| 550 | ** is created on-demand whenever the manifest parser encounters |
| 551 | ** a forum-post artifact. |
| 552 | */ |
| 553 | static const char zForumSchema[] = |
| 554 | @ CREATE TABLE repository.forumpost( |
| 555 | @ fpid INTEGER PRIMARY KEY; -- BLOB.rid for the artifact |
| 556 | @ froot INT; -- fpid of the thread root |
| 557 | @ fprev INT; -- Previous version of this same post |
| 558 | @ firt INT; -- This post is in-reply-to |
| 559 | @ fmtime REAL; -- When posted. Julian day |
| 560 | @ ); |
| 561 | @ CREATE INDEX repository.forumthread ON forumpost(froot); |
| 562 | ; |
| 563 | |
| 564 | /* Create the forum-post schema if it does not already exist */ |
| 565 | void schema_forum(void){ |
| 566 | if( !db_table_exists("repository","forumpost") ){ |
| 567 | db_multi_exec("%s",zForumSchema/*safe-for-%s*/); |
| 568 | } |
| 569 | } |
| 570 |