-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Syfaro/merged-media
Support merging media
- Loading branch information
Showing
50 changed files
with
1,951 additions
and
1,303 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DROP VIEW owned_media_item_accounts; | ||
|
||
DROP TABLE owned_media_item_account; |
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,59 @@ | ||
CREATE TABLE owned_media_item_account ( | ||
owned_media_item_id uuid NOT NULL REFERENCES owned_media_item (id) ON DELETE CASCADE, | ||
account_id uuid NOT NULL REFERENCES linked_account (id) ON DELETE CASCADE, | ||
source_id text NOT NULL, | ||
link text NOT NULL, | ||
title text, | ||
posted_at timestamp with time zone, | ||
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, | ||
PRIMARY KEY (owned_media_item_id, account_id, source_id) | ||
); | ||
|
||
CREATE INDEX owned_media_item_account_lookup_idx ON owned_media_item_account (account_id, source_id); | ||
|
||
CREATE VIEW owned_media_item_accounts ( | ||
id, | ||
owner_id, | ||
perceptual_hash, | ||
sha256_hash, | ||
last_modified, | ||
content_url, | ||
content_size, | ||
thumb_url, | ||
event_count, | ||
last_event, | ||
accounts | ||
) AS | ||
SELECT | ||
owned_media_item.id, | ||
owned_media_item.owner_id, | ||
owned_media_item.perceptual_hash, | ||
owned_media_item.sha256_hash, | ||
owned_media_item.last_modified, | ||
owned_media_item.content_url, | ||
owned_media_item.content_size, | ||
owned_media_item.thumb_url, | ||
owned_media_item.event_count, | ||
owned_media_item.last_event, | ||
jsonb_agg( | ||
jsonb_build_object( | ||
'account_id', | ||
owned_media_item_account.account_id, | ||
'source_id', | ||
owned_media_item_account.source_id, | ||
'link', | ||
owned_media_item_account.link, | ||
'title', | ||
owned_media_item_account.title, | ||
'posted_at', | ||
owned_media_item_account.posted_at | ||
) | ||
) FILTER ( | ||
WHERE | ||
owned_media_item_account.owned_media_item_id IS NOT NULL | ||
) accounts | ||
FROM | ||
owned_media_item | ||
LEFT JOIN owned_media_item_account ON owned_media_item.id = owned_media_item_account.owned_media_item_id | ||
GROUP BY | ||
owned_media_item.id; |
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,2 @@ | ||
ALTER TABLE | ||
user_account DROP COLUMN is_tester; |
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,4 @@ | ||
ALTER TABLE | ||
user_account | ||
ADD | ||
COLUMN is_tester boolean NOT NULL DEFAULT false; |
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,20 @@ | ||
INSERT INTO | ||
owned_media_item_account ( | ||
owned_media_item_id, | ||
account_id, | ||
source_id, | ||
link, | ||
title, | ||
posted_at | ||
) | ||
SELECT | ||
id, | ||
account_id, | ||
source_id, | ||
link, | ||
title, | ||
posted_at | ||
FROM | ||
owned_media_item | ||
WHERE | ||
account_id IS NOT NULL; |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,32 +1,14 @@ | ||
INSERT INTO | ||
owned_media_item ( | ||
owner_id, | ||
account_id, | ||
source_id, | ||
perceptual_hash, | ||
sha256_hash, | ||
link, | ||
title, | ||
posted_at, | ||
last_modified | ||
) | ||
VALUES | ||
( | ||
$1, | ||
$2, | ||
$3, | ||
$4, | ||
$5, | ||
$6, | ||
$7, | ||
$8, | ||
current_timestamp | ||
) ON CONFLICT (account_id, source_id) DO | ||
UPDATE | ||
SET | ||
perceptual_hash = EXCLUDED.perceptual_hash, | ||
sha256_hash = EXCLUDED.sha256_hash, | ||
link = EXCLUDED.link, | ||
title = EXCLUDED.title, | ||
posted_at = EXCLUDED.posted_at, | ||
last_modified = EXCLUDED.last_modified RETURNING id; | ||
) RETURNING id; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
SELECT | ||
id, | ||
owner_id, | ||
account_id, | ||
source_id, | ||
id "id!", | ||
owner_id "owner_id!", | ||
perceptual_hash, | ||
sha256_hash "sha256_hash: Sha256Hash", | ||
link, | ||
title, | ||
posted_at, | ||
last_modified, | ||
sha256_hash "sha256_hash!: Sha256Hash", | ||
last_modified "last_modified!", | ||
content_url, | ||
content_size, | ||
thumb_url, | ||
event_count, | ||
last_event | ||
event_count "event_count!", | ||
last_event, | ||
accounts "accounts: sqlx::types::Json<Vec<OwnedMediaItemAccount>>" | ||
FROM | ||
owned_media_item | ||
owned_media_item_accounts | ||
WHERE | ||
perceptual_hash <@ ($1, $2); |
Oops, something went wrong.