From 8617d41ba7815001fa8d7921cdbf5f060e7ae9db Mon Sep 17 00:00:00 2001 From: Albert G <516972+alber70g@users.noreply.github.com> Date: Fri, 22 Nov 2024 11:22:00 +0100 Subject: [PATCH] chore(graph): remove leftover sql files (#2687) --- .../objects/prisma-pagination-queries.sql | 81 ------------ ...ngible-account-transfers-chainweb-data.sql | 116 ------------------ .../src/graph/objects/simplified-query.sql | 95 -------------- .../graph/objects/union-all-chainweb-data.sql | 55 --------- 4 files changed, 347 deletions(-) delete mode 100644 packages/apps/graph/src/graph/objects/prisma-pagination-queries.sql delete mode 100644 packages/apps/graph/src/graph/objects/query-fungible-account-transfers-chainweb-data.sql delete mode 100644 packages/apps/graph/src/graph/objects/simplified-query.sql delete mode 100644 packages/apps/graph/src/graph/objects/union-all-chainweb-data.sql diff --git a/packages/apps/graph/src/graph/objects/prisma-pagination-queries.sql b/packages/apps/graph/src/graph/objects/prisma-pagination-queries.sql deleted file mode 100644 index 8da0df4b37..0000000000 --- a/packages/apps/graph/src/graph/objects/prisma-pagination-queries.sql +++ /dev/null @@ -1,81 +0,0 @@ --- Prisma reverse query paginating backwards from cursor --- Query: -SELECT - "public"."transfers"."block", - "public"."transfers"."chainid", - "public"."transfers"."idx", - "public"."transfers"."modulehash", - "public"."transfers"."requestkey", - "public"."transfers"."amount", - "public"."transfers"."to_acct", - "public"."transfers"."from_acct", - "public"."transfers"."height" -FROM - "public"."transfers" -WHERE - ( - ( - "public"."transfers"."from_acct" = '$ 1' - OR "public"."transfers"."to_acct" = '$ 2' - ) - AND "public"."transfers"."modulename" = '$ 3' - AND "public"."transfers"."height" >= ( - SELECT - "public"."transfers"."height" - FROM - "public"."transfers" - WHERE - ( - "public"."transfers"."block", - "public"."transfers"."chainid", - "public"."transfers"."idx", - "public"."transfers"."modulehash", - "public"."transfers"."requestkey" - ) = ('$ 4', '$ 5', '$ 6', '$ 7', '$ 8') - ) - ) -ORDER BY - "public"."transfers"."height" ASC OFFSET '$ 9' --- Params: ["k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94","k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94","coin","gMpReKI-O4oaKwXZlmM5WTx5B5fnOjtoM8DrNBVaXpc",1,0,"rE7DU8jlQL9x_MPYuniZJf5ICBTAEHAIFQCB4blofP4","16vVvYgEEkyCljEabcXDYYy7157ObwOdQ6uDI2xvaZc",0] - - - - -- Prisma forward query paginating to next page from cursor - -- Query: -SELECT - "public"."transfers"."block", - "public"."transfers"."chainid", - "public"."transfers"."idx", - "public"."transfers"."modulehash", - "public"."transfers"."requestkey", - "public"."transfers"."amount", - "public"."transfers"."to_acct", - "public"."transfers"."from_acct", - "public"."transfers"."height" -FROM - "public"."transfers" -WHERE - ( - ( - "public"."transfers"."from_acct" = '$ 1' - OR "public"."transfers"."to_acct" = '$ 2' - ) - AND "public"."transfers"."modulename" = '$ 3' - AND "public"."transfers"."height" <= ( - SELECT - "public"."transfers"."height" - FROM - "public"."transfers" - WHERE - ( - "public"."transfers"."block", - "public"."transfers"."chainid", - "public"."transfers"."idx", - "public"."transfers"."modulehash", - "public"."transfers"."requestkey" - ) = ('$ 4', '$ 5', '$ 6', '$ 7', '$ 8') - ) - ) -ORDER BY - "public"."transfers"."height" DESC OFFSET '$ 9' --- Params: ["k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94","k:554754f48b16df24b552f6832dda090642ed9658559fef9f3ee1bb4637ea7c94","coin","gMpReKI-O4oaKwXZlmM5WTx5B5fnOjtoM8DrNBVaXpc",1,2,"rE7DU8jlQL9x_MPYuniZJf5ICBTAEHAIFQCB4blofP4","16vVvYgEEkyCljEabcXDYYy7157ObwOdQ6uDI2xvaZc",0] diff --git a/packages/apps/graph/src/graph/objects/query-fungible-account-transfers-chainweb-data.sql b/packages/apps/graph/src/graph/objects/query-fungible-account-transfers-chainweb-data.sql deleted file mode 100644 index 433a103c5b..0000000000 --- a/packages/apps/graph/src/graph/objects/query-fungible-account-transfers-chainweb-data.sql +++ /dev/null @@ -1,116 +0,0 @@ -WITH transfers_by_acct AS ( - SELECT - * - FROM - ( - SELECT - * - FROM - transfers - WHERE - from_acct = 'k:22fbc926b497bf3ecc7199b923039e74cdeda12726e1dc4f443953007cf8cc43' - ORDER BY - height DESC, - requestkey DESC, - idx ASC - ) as t0 - - UNION ALL - - SELECT - * - FROM - ( - SELECT - * - FROM - transfers - WHERE - to_acct = 'k:22fbc926b497bf3ecc7199b923039e74cdeda12726e1dc4f443953007cf8cc43' - ORDER BY - height DESC, - requestkey DESC, - idx ASC - ) AS t1 -) -SELECT - amount, - block AS block_hash, - chainid AS chain_id, - from_acct AS sender_account, - height, - idx AS order_index, - modulehash AS module_hash, - modulename AS module_name, - requestkey AS request_key, - to_acct AS receiver_account -FROM - transfers_by_acct --- OFFSET WHERE PART -WHERE - ( - "height" <= ( - SELECT - "height" - FROM - "transfers" - WHERE - ( - block, - chainid, - idx, - modulehash, - requestkey - ) = ( - 'I_Oyt-xi7BdmO9hsATRClofuFE-OpVKAFYtT6Vk8oXc', - 1, - 0, - 'rE7DU8jlQL9x_MPYuniZJf5ICBTAEHAIFQCB4blofP4', - '-gE_ZELs7JDixNbvLkfgUy6d0DR-3c54SJe7SG-Xm3A' - ) - ) - ) -ORDER BY - height DESC, - requestkey DESC, - idx ASC OFFSET 100 -LIMIT - 100; - --- QUERY WITH OFFSET built by Prisma --- SELECT --- "public"."transfers"."block", --- "public"."transfers"."chainid", --- "public"."transfers"."idx", --- "public"."transfers"."modulehash", --- "public"."transfers"."requestkey", --- "public"."transfers"."amount", --- "public"."transfers"."to_acct", --- "public"."transfers"."from_acct", --- "public"."transfers"."height" --- FROM --- "public"."transfers" --- WHERE --- ( --- ( --- "public"."transfers"."from_acct" = $1 --- OR "public"."transfers"."to_acct" = $2 --- ) --- AND "public"."transfers"."height" <= ( --- SELECT --- "public"."transfers"."height" --- FROM --- "public"."transfers" --- WHERE --- ( --- "public"."transfers"."block", --- "public"."transfers"."chainid", --- "public"."transfers"."idx", --- "public"."transfers"."modulehash", --- "public"."transfers"."requestkey" --- ) = ($3, $4, $5, $6, $7) --- ) --- ) --- ORDER BY --- "public"."transfers"."height" DESC OFFSET $8 --- Params: ["875e4493e19c8721583bfb46f0768f10266ebcca33c4a0e04bc099a7044a90f7","875e4493e19c8721583bfb46f0768f10266ebcca33c4a0e04bc099a7044a90f7","I_Oyt-xi7BdmO9hsATRClofuFE-OpVKAFYtT6Vk8oXc",1,0,"rE7DU8jlQL9x_MPYuniZJf5ICBTAEHAIFQCB4blofP4","-gE_ZELs7JDixNbvLkfgUy6d0DR-3c54SJe7SG-Xm3A",0] diff --git a/packages/apps/graph/src/graph/objects/simplified-query.sql b/packages/apps/graph/src/graph/objects/simplified-query.sql deleted file mode 100644 index 03c087d27b..0000000000 --- a/packages/apps/graph/src/graph/objects/simplified-query.sql +++ /dev/null @@ -1,95 +0,0 @@ -SELECT - "chainid" AS "chain_id", - "height" AS "height", - "requestkey" AS "request_key", - "idx" AS "order_index" - -- , - -- "block" AS "block_hash", - -- "modulename" AS "module_name", - -- "modulehash" AS "module_hash", - -- "from_acct" AS "sender_account", - -- "to_acct" AS "receiver_account", - -- "amount" AS "amount", - -- "row_number", - -- "is_fungible" -FROM - ( - SELECT - *, - ("modulename") = 'coin' AS "is_fungible", - ROW_NUMBER() OVER ( - ORDER BY - "height" DESC, - "chainid" DESC, - "requestkey" ASC - ) AS "row_number" - FROM - ( - ( - SELECT - * - FROM - "transfers" AS "t0" - WHERE - ("from_acct") = ('w:DD-js2J0pYzsFkqpaTckDmHAH3bVLu5JqwyIbx0yJbg:keys-any') - ORDER BY - "height" DESC, - "chainid" ASC, - "requestkey" DESC, - "idx" ASC - ) - UNION - ALL ( - SELECT - * - FROM - "transfers" - WHERE - ("to_acct") = ('w:DD-js2J0pYzsFkqpaTckDmHAH3bVLu5JqwyIbx0yJbg:keys-any') - ORDER BY - "height" DESC, - "chainid" ASC, - "requestkey" DESC, - "idx" ASC - ) - ) as "t0" - WHERE - ( - ("chainid", "height", "idx", "requestkey") >= ( - SELECT - "chainid", - "height", - "idx", - "requestkey" - FROM - "transfers" - WHERE - ( - block, - chainid, - idx, - modulehash, - requestkey - ) = ( - 'EcLdEV2xp6lYQfPxnlVURn9tlSXNiY8Bwb3QKvwmYYo', - 0, - 1, - 'klFkrLfpyLW-M3xjVPSdqXEMgxPPJibRt_D6qiBws6s', - 'GUfHY6LGd2PJ8eMjO-6HYYyrpCDsw_xC0PIsL4Y5EwM' - ) - ) - ) - LIMIT - 50000 - ) AS "t0" -WHERE - "is_fungible" = true -ORDER BY - "height" DESC, - "chain_id" ASC, - "request_key" DESC, - "order_index" ASC --- OFFSET ${condition?.skip || 0} --- LIMIT ${condition?.take}; -LIMIT 20; - diff --git a/packages/apps/graph/src/graph/objects/union-all-chainweb-data.sql b/packages/apps/graph/src/graph/objects/union-all-chainweb-data.sql deleted file mode 100644 index dadc021fe9..0000000000 --- a/packages/apps/graph/src/graph/objects/union-all-chainweb-data.sql +++ /dev/null @@ -1,55 +0,0 @@ -WITH tr AS ( - -- First subquery: Transfers where the account is the sender - SELECT - amount, - block, - chainid, - from_acct, - height, - idx, - modulehash, - modulename, - requestkey, - to_acct - FROM transfers - WHERE from_acct = :tspAccount - AND (:minHeight IS NULL OR height >= :minHeight) - AND (:maxHeight IS NULL OR height <= :maxHeight) - - UNION ALL - - -- Second subquery: Transfers where the account is the receiver - SELECT - amount, - block, - chainid, - from_acct, - height, - idx, - modulehash, - modulename, - requestkey, - to_acct - FROM transfers - WHERE to_acct = :tspAccount - AND (:minHeight IS NULL OR height >= :minHeight) - AND (:maxHeight IS NULL OR height <= :maxHeight) -) -SELECT - amount, - block AS block_hash, - chainid AS chain_id, - from_acct AS sender_account, - height, - idx AS order_index, - modulehash AS module_hash, - modulename AS module_name, - requestkey AS request_key, - to_acct AS receiver_account -FROM tr -WHERE modulename = :tspToken - AND (:tspChainId IS NULL OR chainid = :tspChainId) -ORDER BY - height DESC, - requestkey DESC, - idx ASC;