WIP: Save attachments - Clean up bad approach
This commit is contained in:
parent
b2d03b59c7
commit
df2155a4e4
|
@ -182,39 +182,6 @@ $$ LANGUAGE sql;
|
||||||
-- 1:21 for full db (nothing inserted)
|
-- 1:21 for full db (nothing inserted)
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Is this even needed?
|
|
||||||
CREATE OR REPLACE FUNCTION insert_attachments_and_return_ids(
|
|
||||||
attachments_payload attachments[])
|
|
||||||
RETURNS TABLE (attachment_id bigint, post_id bigint, sha256_hash text) AS $$
|
|
||||||
WITH
|
|
||||||
selected AS (
|
|
||||||
SELECT attachment_id, post_id, sha256_hash
|
|
||||||
FROM attachments
|
|
||||||
WHERE sha256_hash IN (
|
|
||||||
SELECT sha256_hash FROM unnest(attachments_payload)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
to_insert AS (
|
|
||||||
SELECT new_a.*
|
|
||||||
FROM unnest(attachments_payload) AS new_a
|
|
||||||
LEFT OUTER JOIN selected s
|
|
||||||
ON new_a.sha256_hash = s.sha256_hash
|
|
||||||
WHERE s.attachment_id IS NULL
|
|
||||||
),
|
|
||||||
inserted AS (
|
|
||||||
INSERT INTO attachments (mimetype, creation_time, sha256_hash, phash, illegal, post_id)
|
|
||||||
SELECT mimetype, creation_time, sha256_hash, phash, illegal, post_id
|
|
||||||
FROM to_insert
|
|
||||||
RETURNING attachment_id, post_id, sha256_hash
|
|
||||||
)
|
|
||||||
SELECT * FROM inserted
|
|
||||||
UNION ALL
|
|
||||||
SELECT * FROM selected;
|
|
||||||
$$ LANGUAGE sql;
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION fetch_top_threads(
|
CREATE OR REPLACE FUNCTION fetch_top_threads(
|
||||||
p_start_time TIMESTAMPTZ,
|
p_start_time TIMESTAMPTZ,
|
||||||
lookback INT DEFAULT 10000
|
lookback INT DEFAULT 10000
|
||||||
|
|
|
@ -192,17 +192,6 @@ postPosts settings posts =
|
||||||
where
|
where
|
||||||
payload = encode $ object [ "new_posts" .= posts ]
|
payload = encode $ object [ "new_posts" .= posts ]
|
||||||
|
|
||||||
{-
|
|
||||||
postAttachments
|
|
||||||
:: T.JSONSettings
|
|
||||||
-> [ Attachments.Attachment ]
|
|
||||||
-> IO (Either HttpError [ AttachmentId ])
|
|
||||||
postAttachments settings attachments =
|
|
||||||
post settings "/rpc/insert_attachments_and_return_ids" payload True >>= return . eitherDecodeResponse
|
|
||||||
|
|
||||||
where
|
|
||||||
payload = encode $ object [ "attachments_payload" .= attachments ]
|
|
||||||
-}
|
|
||||||
|
|
||||||
eitherDecodeResponse :: (FromJSON a) => Either HttpError LBS.ByteString -> Either HttpError a
|
eitherDecodeResponse :: (FromJSON a) => Either HttpError LBS.ByteString -> Either HttpError a
|
||||||
eitherDecodeResponse (Left err) = Left err
|
eitherDecodeResponse (Left err) = Left err
|
||||||
|
|
Loading…
Reference in New Issue