-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use rpc for pins upsert (#1088)
* fix: use rpc for pins upsert * fix: lint correction * fix: remove code duplication in functions * fix: included ipfs peerid + now returning pin ids * fix: cron mock for upsert pins * chore: add migration script, adjust mock * fix: improve pin_location insert * fix: corrected migration
- Loading branch information
1 parent
72b8073
commit 6a8e394
Showing
8 changed files
with
71 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["1", "2", "3"] |
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
20 changes: 20 additions & 0 deletions
20
packages/db/postgres/migrations/005-add-upsert-pins-function.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,20 @@ | ||
DROP FUNCTION IF EXISTS upsert_pins; | ||
|
||
CREATE OR REPLACE FUNCTION upsert_pins(data json) RETURNS TEXT[] | ||
LANGUAGE plpgsql | ||
volatile | ||
PARALLEL UNSAFE | ||
AS | ||
$$ | ||
DECLARE | ||
pin json; | ||
pin_ids TEXT[]; | ||
BEGIN | ||
FOREACH pin IN array json_arr_to_json_element_array(data -> 'pins') | ||
LOOP | ||
SELECT pin_ids || upsert_pin(pin -> 'data') INTO pin_ids; | ||
END LOOP; | ||
|
||
RETURN pin_ids; | ||
END | ||
$$; |
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