diff --git a/sql/initialize.sql b/sql/initialize.sql index dd58cc7..3f5fe46 100644 --- a/sql/initialize.sql +++ b/sql/initialize.sql @@ -182,39 +182,6 @@ $$ LANGUAGE sql; -- 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( p_start_time TIMESTAMPTZ, lookback INT DEFAULT 10000 diff --git a/src/DataClient.hs b/src/DataClient.hs index c5682c1..2574f29 100644 --- a/src/DataClient.hs +++ b/src/DataClient.hs @@ -192,17 +192,6 @@ postPosts settings posts = where 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 (Left err) = Left err