From b9a8fa1fc96f5556b0b5ae2568d507d7edc1ba3d Mon Sep 17 00:00:00 2001 From: Bogdan Crisan Date: Fri, 28 Jun 2024 12:20:23 +0200 Subject: [PATCH] add mypools route --- cfg/cspell-dictionary.txt | 1 + sql_extensions/migrations/00005_my_pools.sql | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 sql_extensions/migrations/00005_my_pools.sql diff --git a/cfg/cspell-dictionary.txt b/cfg/cspell-dictionary.txt index 20c9134..6348880 100644 --- a/cfg/cspell-dictionary.txt +++ b/cfg/cspell-dictionary.txt @@ -40,6 +40,7 @@ mdformat mosquitto mqtt mqttoptions +mypools noqa notif pgrep diff --git a/sql_extensions/migrations/00005_my_pools.sql b/sql_extensions/migrations/00005_my_pools.sql new file mode 100644 index 0000000..2c4544c --- /dev/null +++ b/sql_extensions/migrations/00005_my_pools.sql @@ -0,0 +1,16 @@ +CREATE INDEX inbox_events_mypools ON inbox_events ( + (data ->> 'provider') +) WHERE event_name = 'emojicoin_dot_fun::Liquidity' AND (data ->> 'liquidity_provided')::BOOLEAN = true; + +-- noqa: disable=PRS +CREATE FUNCTION mypools (address text) RETURNS TABLE (LIKE market_data) AS +$$ + WITH mypools AS ( + SELECT DISTINCT (data ->> 'market_id')::NUMERIC AS market_id + FROM inbox_events + WHERE event_name = 'emojicoin_dot_fun::Liquidity' + AND (data ->> 'liquidity_provided')::BOOLEAN = true + AND (data ->> 'provider') = $1 + ) + SELECT m.* FROM market_data m INNER JOIN mypools p ON m.market_id = p.market_id; +$$ LANGUAGE SQL;