Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: all_ecocredit_txes to use msg.data->@type instead of msg_event.type #56

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions migrations/committed/000001.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--! Previous: -
--! Hash: sha1:5ad90bce5c5fb68d0a8f886b6c07fb280ccd2c42

CREATE INDEX IF NOT EXISTS msg_data_type_idx ON msg USING BTREE ((DATA -> '@type'));

DROP FUNCTION IF EXISTS all_ecocredit_txes;

CREATE FUNCTION public.all_ecocredit_txes() RETURNS SETOF public.tx
LANGUAGE sql STABLE
AS $$
select tx.*
from tx
inner join msg using (chain_num, block_height, tx_idx)
where
tx.data ->'tx_response'->'code' = '0' and
msg.data->>'@type' like '/regen.ecocredit.%'
order by tx.block_height desc
$$;
27 changes: 21 additions & 6 deletions migrations/schema_snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- PostgreSQL database dump
--

-- Dumped from database version 14.9 (Homebrew)
-- Dumped by pg_dump version 14.9 (Homebrew)
-- Dumped from database version 14.9 (Debian 14.9-1.pgdg110+1)
-- Dumped by pg_dump version 15.4

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand All @@ -23,6 +23,13 @@ SET row_security = off;
CREATE SCHEMA graphile_migrate;


--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--

-- *not* creating schema, since initdb creates it


--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
Expand Down Expand Up @@ -77,10 +84,10 @@ CREATE FUNCTION public.all_ecocredit_txes() RETURNS SETOF public.tx
AS $$
select tx.*
from tx
natural join msg_event as me
inner join msg using (chain_num, block_height, tx_idx)
where
data ->'tx_response'->'code' = '0'
and me.type like 'regen.ecocredit.%'
tx.data ->'tx_response'->'code' = '0' and
msg.data->>'@type' like '/regen.ecocredit.%'
order by tx.block_height desc
$$;

Expand Down Expand Up @@ -571,6 +578,13 @@ CREATE INDEX class_issuers_latest_idx ON public.class_issuers USING btree (lates
CREATE INDEX flyway_schema_history_s_idx ON public.flyway_schema_history USING btree (success);


--
-- Name: msg_data_type_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX msg_data_type_idx ON public.msg USING btree (((data -> '@type'::text)));


--
-- Name: msg_event_attr_type_idx; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -711,7 +725,8 @@ ALTER TABLE ONLY public.votes
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: -
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
REVOKE USAGE ON SCHEMA public FROM PUBLIC;


--
Expand Down