-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add logic to update community statements with cron job
- Loading branch information
Showing
6 changed files
with
378 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
database/test/units/functions/pgwar-update-community-statements-from-deletes.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
BEGIN; | ||
|
||
SELECT plan(3); | ||
|
||
INSERT INTO pgwar.community_statements ( | ||
pk_entity, | ||
fk_subject_info, | ||
fk_property, | ||
fk_object_info, | ||
ord_num_of_domain, | ||
ord_num_of_range, | ||
object_label | ||
) | ||
VALUES | ||
(1, 99, 22, 11, 0, 0, 'LABEL'), | ||
(2, 66, 22, 11, 4, 3, 'LABEL'), | ||
(3, 44, 22, 11, 4, 3, 'LABEL'); | ||
|
||
|
||
INSERT INTO pgwar.project_statements ( | ||
pk_entity, | ||
fk_project, | ||
fk_subject_info, | ||
fk_property, | ||
fk_object_info, | ||
ord_num_of_domain, | ||
ord_num_of_range, | ||
object_label | ||
) | ||
VALUES | ||
(1, 31, 99, 22, 11, 4, 3, 'LABEL'), | ||
(1, 32, 99, 22, 11, 8, 1, 'LABEL'), | ||
(2, 31, 66, 22, 11, 4, 3, 'LABEL'), | ||
(2, 32, 66, 22, 11, 4, 3, 'LABEL'); | ||
|
||
|
||
INSERT INTO pgwar.project_statements_deleted ( | ||
pk_entity, | ||
fk_project, | ||
fk_subject_info, | ||
fk_property, | ||
fk_object_info, | ||
tmsp_deletion | ||
) | ||
VALUES | ||
(1, 8765, 99, 22, 11, CURRENT_TIMESTAMP), | ||
(3, 8765, 44, 22, 11, CURRENT_TIMESTAMP); | ||
|
||
|
||
-- run the update task | ||
SELECT pgwar.update_community_statements_from_deletes(); | ||
|
||
SELECT is( | ||
ord_num_of_domain, | ||
6::numeric, | ||
'Assert the ord nums are recalculated for community statement with pk_entity 1' | ||
) | ||
FROM pgwar.community_statements | ||
WHERE pk_entity = 1; | ||
|
||
SELECT is_empty( | ||
'SELECT * FROM pgwar.community_statements WHERE pk_entity = 3;', | ||
'Assert community statement with pk_entity 3 is deleted' | ||
); | ||
|
||
SELECT is( | ||
offset_tmsp, | ||
CURRENT_TIMESTAMP, | ||
'Assert that offset is updated' | ||
) | ||
FROM pgwar.offsets | ||
WHERE job_name = 'update-community-statements-from-deletes'; | ||
|
||
SELECT * | ||
FROM finish(); | ||
|
||
ROLLBACK; |
Oops, something went wrong.