From 41f2780731b00ffb68995b294bfd5b3626695e7d Mon Sep 17 00:00:00 2001 From: Priyank <3169068+rdlrt@users.noreply.github.com> Date: Fri, 11 Aug 2023 18:48:49 +1000 Subject: [PATCH] pool_list: Add all cache fields & remove filter --- files/grest/rpc/pool/pool_list.sql | 69 ++++++++++++++++++++--------- specs/results/koiosapi-guild.yaml | 31 ++++++++++--- specs/results/koiosapi-mainnet.yaml | 31 ++++++++++--- specs/results/koiosapi-preprod.yaml | 31 ++++++++++--- specs/results/koiosapi-preview.yaml | 31 ++++++++++--- specs/templates/4-api-schemas.yaml | 31 ++++++++++--- 6 files changed, 177 insertions(+), 47 deletions(-) diff --git a/files/grest/rpc/pool/pool_list.sql b/files/grest/rpc/pool/pool_list.sql index c656d274..3d8ce843 100644 --- a/files/grest/rpc/pool/pool_list.sql +++ b/files/grest/rpc/pool/pool_list.sql @@ -1,7 +1,19 @@ CREATE OR REPLACE FUNCTION grest.pool_list() RETURNS TABLE ( pool_id_bech32 character varying, - ticker character varying + pool_id_hex text, + active_epoch_no bigint, + margin double precision, + fixed_cost text, + pledge text, + reward_addr character varying, + owners character varying [], + relays jsonb [], + ticker character varying, + meta_url character varying, + meta_hash text, + pool_status text, + retiring_epoch word31type ) LANGUAGE plpgsql AS $$ @@ -12,36 +24,49 @@ BEGIN -- Get last pool update for each pool _pool_list AS ( SELECT - DISTINCT ON (pic.pool_id_bech32) pool_id_bech32, - pool_status - FROM - grest.pool_info_cache AS pic - ORDER BY - pic.pool_id_bech32, - pic.tx_id DESC + ph.view as pool_id_bech32, + ph.hash_raw as pool_id_hex + FROM pool_hash AS ph ), _pool_meta AS ( - SELECT - DISTINCT ON (pic.pool_id_bech32) pool_id_bech32, - pod.ticker_name - FROM - grest.pool_info_cache AS pic - LEFT JOIN public.pool_offline_data AS pod ON pod.pmr_id = pic.meta_id - WHERE pod.ticker_name IS NOT NULL + SELECT DISTINCT ON (pic.pool_id_bech32) + pic.pool_id_bech32, + pic.active_epoch_no, + pic.margin, + pic.fixed_cost, + pic.pledge, + pic.reward_addr, + pic.owners, + pic.relays, + pod.ticker_name, + pic.meta_url, + pic.meta_hash, + pic.pool_status, + pic.retiring_epoch + FROM grest.pool_info_cache AS pic + LEFT JOIN public.pool_offline_data AS pod ON pod.pmr_id = pic.meta_id ORDER BY pic.pool_id_bech32, pic.tx_id DESC ) - SELECT pl.pool_id_bech32, - pm.ticker_name - FROM - _pool_list AS pl - LEFT JOIN _pool_meta AS pm ON pl.pool_id_bech32 = pm.pool_id_bech32 - WHERE - pool_status != 'retired' + encode(pl.pool_id_hex,'hex') as pool_id_hex, + pm.active_epoch_no, + pm.margin, + pm.fixed_cost::text, + pm.pledge::text, + pm.reward_addr, + pm.owners, + pm.relays, + pm.ticker_name, + pm.meta_url, + pm.meta_hash, + pm.pool_status, + pm.retiring_epoch + FROM _pool_list AS pl + LEFT JOIN _pool_meta AS pm ON pl.pool_id_bech32 = pm.pool_id_bech32 ); END; $$; diff --git a/specs/results/koiosapi-guild.yaml b/specs/results/koiosapi-guild.yaml index 2027146d..13271f25 100644 --- a/specs/results/koiosapi-guild.yaml +++ b/specs/results/koiosapi-guild.yaml @@ -2008,15 +2008,36 @@ components: items: properties: pool_id_bech32: - type: string - nullable: true - description: Bech32 representation of pool ID - example: pool1z5uqdk7dzdxaae5633fqfcu2eqzy3a3rgtuvy087fdld7yws0xt + $ref: "#/components/schemas/pool_info/items/properties/pool_id_bech32" + pool_id_hex: + $ref: "#/components/schemas/pool_info/items/properties/pool_id_hex" + active_epoch_no: + $ref: "#/components/schemas/pool_info/items/properties/active_epoch_no" + margin: + $ref: "#/components/schemas/pool_info/items/properties/margin" + fixed_cost: + $ref: "#/components/schemas/pool_info/items/properties/fixed_cost" + pledge: + $ref: "#/components/schemas/pool_info/items/properties/pledge" + reward_addr: + $ref: "#/components/schemas/pool_info/items/properties/reward_addr" + owners: + $ref: "#/components/schemas/pool_info/items/properties/margin" + relays: + $ref: "#/components/schemas/pool_info/items/properties/margin" ticker: type: string nullable: true description: Pool ticker - example: JAZZ + example: AHL + meta_url: + $ref: "#/components/schemas/pool_info/items/properties/margin" + meta_hash: + $ref: "#/components/schemas/pool_info/items/properties/margin" + pool_status: + $ref: "#/components/schemas/pool_info/items/properties/margin" + retiring_epoch: + $ref: "#/components/schemas/pool_info/items/properties/margin" pool_history_info: type: array items: diff --git a/specs/results/koiosapi-mainnet.yaml b/specs/results/koiosapi-mainnet.yaml index f9d5c3e0..0b54c63b 100644 --- a/specs/results/koiosapi-mainnet.yaml +++ b/specs/results/koiosapi-mainnet.yaml @@ -2008,15 +2008,36 @@ components: items: properties: pool_id_bech32: - type: string - nullable: true - description: Bech32 representation of pool ID - example: pool1z5uqdk7dzdxaae5633fqfcu2eqzy3a3rgtuvy087fdld7yws0xt + $ref: "#/components/schemas/pool_info/items/properties/pool_id_bech32" + pool_id_hex: + $ref: "#/components/schemas/pool_info/items/properties/pool_id_hex" + active_epoch_no: + $ref: "#/components/schemas/pool_info/items/properties/active_epoch_no" + margin: + $ref: "#/components/schemas/pool_info/items/properties/margin" + fixed_cost: + $ref: "#/components/schemas/pool_info/items/properties/fixed_cost" + pledge: + $ref: "#/components/schemas/pool_info/items/properties/pledge" + reward_addr: + $ref: "#/components/schemas/pool_info/items/properties/reward_addr" + owners: + $ref: "#/components/schemas/pool_info/items/properties/margin" + relays: + $ref: "#/components/schemas/pool_info/items/properties/margin" ticker: type: string nullable: true description: Pool ticker - example: JAZZ + example: AHL + meta_url: + $ref: "#/components/schemas/pool_info/items/properties/margin" + meta_hash: + $ref: "#/components/schemas/pool_info/items/properties/margin" + pool_status: + $ref: "#/components/schemas/pool_info/items/properties/margin" + retiring_epoch: + $ref: "#/components/schemas/pool_info/items/properties/margin" pool_history_info: type: array items: diff --git a/specs/results/koiosapi-preprod.yaml b/specs/results/koiosapi-preprod.yaml index 6d956f7c..cfefff55 100644 --- a/specs/results/koiosapi-preprod.yaml +++ b/specs/results/koiosapi-preprod.yaml @@ -2008,15 +2008,36 @@ components: items: properties: pool_id_bech32: - type: string - nullable: true - description: Bech32 representation of pool ID - example: pool1z5uqdk7dzdxaae5633fqfcu2eqzy3a3rgtuvy087fdld7yws0xt + $ref: "#/components/schemas/pool_info/items/properties/pool_id_bech32" + pool_id_hex: + $ref: "#/components/schemas/pool_info/items/properties/pool_id_hex" + active_epoch_no: + $ref: "#/components/schemas/pool_info/items/properties/active_epoch_no" + margin: + $ref: "#/components/schemas/pool_info/items/properties/margin" + fixed_cost: + $ref: "#/components/schemas/pool_info/items/properties/fixed_cost" + pledge: + $ref: "#/components/schemas/pool_info/items/properties/pledge" + reward_addr: + $ref: "#/components/schemas/pool_info/items/properties/reward_addr" + owners: + $ref: "#/components/schemas/pool_info/items/properties/margin" + relays: + $ref: "#/components/schemas/pool_info/items/properties/margin" ticker: type: string nullable: true description: Pool ticker - example: JAZZ + example: AHL + meta_url: + $ref: "#/components/schemas/pool_info/items/properties/margin" + meta_hash: + $ref: "#/components/schemas/pool_info/items/properties/margin" + pool_status: + $ref: "#/components/schemas/pool_info/items/properties/margin" + retiring_epoch: + $ref: "#/components/schemas/pool_info/items/properties/margin" pool_history_info: type: array items: diff --git a/specs/results/koiosapi-preview.yaml b/specs/results/koiosapi-preview.yaml index debc78c1..177cdd5b 100644 --- a/specs/results/koiosapi-preview.yaml +++ b/specs/results/koiosapi-preview.yaml @@ -2008,15 +2008,36 @@ components: items: properties: pool_id_bech32: - type: string - nullable: true - description: Bech32 representation of pool ID - example: pool1z5uqdk7dzdxaae5633fqfcu2eqzy3a3rgtuvy087fdld7yws0xt + $ref: "#/components/schemas/pool_info/items/properties/pool_id_bech32" + pool_id_hex: + $ref: "#/components/schemas/pool_info/items/properties/pool_id_hex" + active_epoch_no: + $ref: "#/components/schemas/pool_info/items/properties/active_epoch_no" + margin: + $ref: "#/components/schemas/pool_info/items/properties/margin" + fixed_cost: + $ref: "#/components/schemas/pool_info/items/properties/fixed_cost" + pledge: + $ref: "#/components/schemas/pool_info/items/properties/pledge" + reward_addr: + $ref: "#/components/schemas/pool_info/items/properties/reward_addr" + owners: + $ref: "#/components/schemas/pool_info/items/properties/margin" + relays: + $ref: "#/components/schemas/pool_info/items/properties/margin" ticker: type: string nullable: true description: Pool ticker - example: JAZZ + example: AHL + meta_url: + $ref: "#/components/schemas/pool_info/items/properties/margin" + meta_hash: + $ref: "#/components/schemas/pool_info/items/properties/margin" + pool_status: + $ref: "#/components/schemas/pool_info/items/properties/margin" + retiring_epoch: + $ref: "#/components/schemas/pool_info/items/properties/margin" pool_history_info: type: array items: diff --git a/specs/templates/4-api-schemas.yaml b/specs/templates/4-api-schemas.yaml index 09703f3a..3e31a45b 100644 --- a/specs/templates/4-api-schemas.yaml +++ b/specs/templates/4-api-schemas.yaml @@ -116,15 +116,36 @@ schemas: items: properties: pool_id_bech32: - type: string - nullable: true - description: Bech32 representation of pool ID - example: pool1z5uqdk7dzdxaae5633fqfcu2eqzy3a3rgtuvy087fdld7yws0xt + $ref: "#/components/schemas/pool_info/items/properties/pool_id_bech32" + pool_id_hex: + $ref: "#/components/schemas/pool_info/items/properties/pool_id_hex" + active_epoch_no: + $ref: "#/components/schemas/pool_info/items/properties/active_epoch_no" + margin: + $ref: "#/components/schemas/pool_info/items/properties/margin" + fixed_cost: + $ref: "#/components/schemas/pool_info/items/properties/fixed_cost" + pledge: + $ref: "#/components/schemas/pool_info/items/properties/pledge" + reward_addr: + $ref: "#/components/schemas/pool_info/items/properties/reward_addr" + owners: + $ref: "#/components/schemas/pool_info/items/properties/margin" + relays: + $ref: "#/components/schemas/pool_info/items/properties/margin" ticker: type: string nullable: true description: Pool ticker - example: JAZZ + example: AHL + meta_url: + $ref: "#/components/schemas/pool_info/items/properties/margin" + meta_hash: + $ref: "#/components/schemas/pool_info/items/properties/margin" + pool_status: + $ref: "#/components/schemas/pool_info/items/properties/margin" + retiring_epoch: + $ref: "#/components/schemas/pool_info/items/properties/margin" pool_history_info: type: array items: