Skip to content

Commit

Permalink
Add a column to count the number of target selectors to annotations
Browse files Browse the repository at this point in the history
We intend to use whether we have targets to work out what type of annotation
we have. We can use this to differentiate between replies, page notes and
others.
  • Loading branch information
Jon Betts committed Jun 8, 2023
1 parent 53d904e commit b70cdf1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CREATE TABLE report.annotations (
updated TIMESTAMP NOT NULL,
deleted BOOLEAN NOT NULL,
shared BOOLEAN NOT NULL,
target_selectors INT NOT NULL,
size INT,
parent_uuids UUID[],
tags TEXT[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ INSERT INTO report.annotations (
uuid,
user_id, group_id, document_id, authority_id,
created, updated,
deleted, shared, size,
deleted, shared, target_selectors, size,
parent_uuids, tags
)
SELECT
Expand All @@ -26,6 +26,7 @@ SELECT
annotation.updated,
deleted,
shared,
JSONB_ARRAY_LENGTH(target_selectors) AS target_selectors,
LENGTH(text) AS size,
"references",
tags
Expand Down
4 changes: 3 additions & 1 deletion h/data_tasks/report/refresh/01_annotations_refresh.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ INSERT INTO report.annotations (
uuid,
user_id, group_id, document_id, authority_id,
created, updated,
deleted, shared, size,
deleted, shared, target_selectors, size,
parent_uuids, tags
)
SELECT
Expand All @@ -30,6 +30,7 @@ SELECT
annotation.updated::date,
deleted,
shared,
JSONB_ARRAY_LENGTH(target_selectors) AS target_selectors,
LENGTH(text) AS size,
"references",
tags
Expand All @@ -51,6 +52,7 @@ ON CONFLICT (uuid) DO UPDATE SET
group_id=EXCLUDED.group_id,
deleted=EXCLUDED.deleted,
shared=EXCLUDED.shared,
target_selectors=EXCLUDED.target_selectors,
size=EXCLUDED.size,
parent_uuids=EXCLUDED.parent_uuids,
tags=EXCLUDED.tags;
Expand Down

0 comments on commit b70cdf1

Please sign in to comment.