Skip to content

Commit

Permalink
pool_list: Add all cache fields & remove filter
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlrt committed Aug 11, 2023
1 parent f1e2d9e commit 41f2780
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 47 deletions.
69 changes: 47 additions & 22 deletions files/grest/rpc/pool/pool_list.sql
Original file line number Diff line number Diff line change
@@ -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 $$
Expand All @@ -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;
$$;
31 changes: 26 additions & 5 deletions specs/results/koiosapi-guild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 26 additions & 5 deletions specs/results/koiosapi-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 26 additions & 5 deletions specs/results/koiosapi-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 26 additions & 5 deletions specs/results/koiosapi-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 26 additions & 5 deletions specs/templates/4-api-schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 41f2780

Please sign in to comment.