You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exports[`pairs daemon sql test fill table 1`] = `"insert into \\"pairs\\" with \\"pairs_cte\\" as (select \\"amount_asset_id\\" as \\"amount_asset_id\\", \\"price_asset_id\\" as \\"price_asset_id\\", (array_agg(e.price ORDER BY e.uid DESC)::numeric[])[1] as \\"last_price\\", (array_agg(e.price ORDER BY e.uid)::numeric[])[1] as \\"first_price\\", sum(e.amount) as \\"volume\\", sum(e.amount::numeric * e.price::numeric) as \\"quote_volume\\", floor(sum(e.amount::numeric * e.price::numeric)/ sum(e.amount)) as \\"weighted_average_price\\", case when amount_asset_id='WAVES' then sum(e.amount) when price_asset_id='WAVES' then sum(e.amount::numeric * e.price::numeric) end as \\"volume_waves\\", max(e.price) as \\"high\\", min(e.price) as \\"low\\", count(e.price) as \\"txs_count\\", \\"sender\\" as \\"matcher_address\\" from (with \\"hp_cte\\" as (select \\"uid\\" from \\"txs\\" where time_stamp >= now() - interval '1 day' limit 1) select \\"t\\".\\"uid\\" as \\"uid\\", \\"t\\".\\"amount_asset_id\\" as \\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" as \\"price_asset_id\\", \\"t\\".\\"amount\\" as \\"amount\\", \\"t\\".\\"price\\" as \\"price\\", \\"t\\".\\"time_stamp\\" as \\"time_stamp\\", \\"t\\".\\"sender\\" as \\"sender\\" from \\"txs_7\\" as \\"t\\" where \\"t\\".\\"uid\\" >= (select \\"uid\\" from \\"hp_cte\\") order by \\"t\\".\\"uid\\" desc) as \\"e\\" group by \\"amount_asset_id\\", \\"price_asset_id\\", \\"sender\\") select \\"p\\".\\"amount_asset_id\\", \\"p\\".\\"price_asset_id\\", \\"p\\".\\"first_price\\", \\"p\\".\\"last_price\\", \\"p\\".\\"volume\\", coalesce(p.volume_waves, floor(p.quote_volume / p1.weighted_average_price), p.quote_volume * p2.weighted_average_price) as \\"volume_waves\\", \\"p\\".\\"quote_volume\\", \\"p\\".\\"high\\", \\"p\\".\\"low\\", \\"p\\".\\"weighted_average_price\\", \\"p\\".\\"txs_count\\", \\"p\\".\\"matcher_address\\" from \\"pairs_cte\\" as \\"p\\" left join \\"pairs_cte\\" as \\"p1\\" on p1.amount_asset_id='WAVES' and \\"p1\\".\\"price_asset_id\\" = \\"p\\".\\"price_asset_id\\" and \\"p1\\".\\"matcher_address\\" = \\"p\\".\\"matcher_address\\" left join \\"pairs_cte\\" as \\"p2\\" on \\"p2\\".\\"amount_asset_id\\" = \\"p\\".\\"price_asset_id\\" and p2.price_asset_id='WAVES' and \\"p2\\".\\"matcher_address\\" = \\"p\\".\\"matcher_address\\""`;
3
+
exports[`pairs daemon sql test fill table 1`] = `"insert into \\"pairs\\" with \\"pairs_cte\\" as (select \\"amount_asset_id\\" as \\"amount_asset_id\\", \\"price_asset_id\\" as \\"price_asset_id\\", (array_agg(e.price ORDER BY e.uid DESC)::numeric[])[1] as \\"last_price\\", (array_agg(e.price ORDER BY e.uid)::numeric[])[1] as \\"first_price\\", sum(e.amount) as \\"volume\\", sum(e.amount::numeric * e.price::numeric) as \\"quote_volume\\", floor(sum(e.amount::numeric * e.price::numeric)/ sum(e.amount)) as \\"weighted_average_price\\", case when amount_asset_id='WAVES' then sum(e.amount) when price_asset_id='WAVES' then sum(e.amount::numeric * e.price::numeric) end as \\"volume_waves\\", max(e.price) as \\"high\\", min(e.price) as \\"low\\", count(e.price) as \\"txs_count\\", \\"sender\\" as \\"matcher_address\\" from (select \\"t\\".\\"uid\\" as \\"uid\\", \\"t\\".\\"amount_asset_id\\" as \\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" as \\"price_asset_id\\", \\"t\\".\\"amount\\" as \\"amount\\", \\"t\\".\\"price\\" as \\"price\\", \\"t\\".\\"time_stamp\\" as \\"time_stamp\\", \\"t\\".\\"sender\\" as \\"sender\\" from \\"txs_7\\" as \\"t\\" where time_stamp >= now() - interval '1 day' order by \\"t\\".\\"uid\\" desc, time_stamp <-> now() - interval '1 day') as \\"e\\" group by \\"amount_asset_id\\", \\"price_asset_id\\", \\"sender\\") select \\"p\\".\\"amount_asset_id\\", \\"p\\".\\"price_asset_id\\", \\"p\\".\\"first_price\\", \\"p\\".\\"last_price\\", \\"p\\".\\"volume\\", COALESCE(p.volume_waves, floor(p.quote_volume / p1.weighted_average_price), p.quote_volume * p2.weighted_average_price) as \\"volume_waves\\", \\"p\\".\\"quote_volume\\", \\"p\\".\\"high\\", \\"p\\".\\"low\\", \\"p\\".\\"weighted_average_price\\", \\"p\\".\\"txs_count\\", \\"p\\".\\"matcher_address\\" from \\"pairs_cte\\" as \\"p\\" left join \\"pairs_cte\\" as \\"p1\\" on p1.amount_asset_id='WAVES' and \\"p1\\".\\"price_asset_id\\" = \\"p\\".\\"price_asset_id\\" and \\"p1\\".\\"matcher_address\\" = \\"p\\".\\"matcher_address\\" left join \\"pairs_cte\\" as \\"p2\\" on \\"p2\\".\\"amount_asset_id\\" = \\"p\\".\\"price_asset_id\\" and p2.price_asset_id='WAVES' and \\"p2\\".\\"matcher_address\\" = \\"p\\".\\"matcher_address\\""`;
Copy file name to clipboardExpand all lines: src/services/pairs/repo/__test__/__snapshots__/sql.test.ts.snap
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@ exports[`sql query from pairs should get many pairs 1`] = `"select \\"first_pric
4
4
5
5
exports[`sql query from pairs should get one pair 1`] =`"select \\"first_price\\", \\"last_price\\", \\"volume\\", \\"quote_volume\\", \\"high\\", \\"low\\", \\"weighted_average_price\\", \\"txs_count\\", \\"volume_waves\\", \\"amount_asset_id\\", \\"price_asset_id\\" from \\"pairs\\" as \\"t\\" where (\\"t\\".\\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\") in (('111', '222')) and \\"matcher_address\\" = '333'"`;
6
6
7
-
exports[`sql query from pairs should search pairs for one asset 1`] = `"with \\"assets_cte\\" as (select distinct \\"asset_id\\" from (select \\"t\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t\\" where \\"t\\".\\"asset_id\\" = '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' or \\"t\\".\\"ticker\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj%' union all select \\"t2\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets_metadata\\" as \\"t2\\" where \\"t2\\".\\"asset_name\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj%' union all select \\"t3\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t3\\" where \\"t3\\".\\"asset_name\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj%' or to_tsvector('simple', t3.asset_name) @@ to_tsquery('7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj:*')) as \\"a\\") select \\"t\\".\\"first_price\\", \\"t\\".\\"last_price\\", \\"t\\".\\"volume\\", \\"t\\".\\"quote_volume\\", \\"t\\".\\"high\\", \\"t\\".\\"low\\", \\"t\\".\\"weighted_average_price\\", \\"t\\".\\"txs_count\\", \\"t\\".\\"volume_waves\\", \\"t\\".\\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" from \\"pairs\\" as \\"t\\" where \\"matcher_address\\" = '' order by volume_waves desc NULLS LAST limit 10"`;
7
+
exports[`sql query from pairs should search pairs for one asset 1`] = `"with \\"assets_cte\\" as (select distinct \\"asset_id\\" from (select \\"t\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t\\" where \\"t\\".\\"asset_id\\" = '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' or \\"t\\".\\"ticker\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj%' union all select \\"t2\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets_metadata\\" as \\"t2\\" where \\"t2\\".\\"asset_name\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj%' union all select \\"t3\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t3\\" where \\"t3\\".\\"asset_name\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj%' or to_tsvector('simple', t3.asset_name) @@ to_tsquery('7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj:*')) as \\"a\\") select \\"t\\".\\"first_price\\", \\"t\\".\\"last_price\\", \\"t\\".\\"volume\\", \\"t\\".\\"quote_volume\\", \\"t\\".\\"high\\", \\"t\\".\\"low\\", \\"t\\".\\"weighted_average_price\\", \\"t\\".\\"txs_count\\", \\"t\\".\\"volume_waves\\", \\"t\\".\\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" from \\"pairs\\" as \\"t\\" inner join \\"assets_cte\\" as \\"amount_cte\\" on \\"amount_cte\\".\\"asset_id\\" = \\"t\\".\\"amount_asset_id\\" inner join \\"assets_cte\\" as \\"price_cte\\" on \\"price_cte\\".\\"asset_id\\" = \\"t\\".\\"amount_asset_id\\" where \\"matcher_address\\" = '' order by volume_waves desc NULLS LAST limit 10"`;
8
8
9
-
exports[`sql query from pairs should search pairs for one asset exactly 1`] = `"with \\"assets_cte\\" as (select distinct \\"asset_id\\" from (select \\"t\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t\\" where \\"t\\".\\"asset_id\\" = '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' or \\"t\\".\\"ticker\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' union all select \\"t2\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets_metadata\\" as \\"t2\\" where \\"t2\\".\\"asset_name\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' union all select \\"t3\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t3\\" where \\"t3\\".\\"asset_name\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' or to_tsvector('simple', t3.asset_name) @@ to_tsquery('7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj:*')) as \\"a\\") select \\"t\\".\\"first_price\\", \\"t\\".\\"last_price\\", \\"t\\".\\"volume\\", \\"t\\".\\"quote_volume\\", \\"t\\".\\"high\\", \\"t\\".\\"low\\", \\"t\\".\\"weighted_average_price\\", \\"t\\".\\"txs_count\\", \\"t\\".\\"volume_waves\\", \\"t\\".\\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" from \\"pairs\\" as \\"t\\" where \\"matcher_address\\" = '' order by volume_waves desc NULLS LAST limit 10"`;
9
+
exports[`sql query from pairs should search pairs for one asset exactly 1`] = `"with \\"assets_cte\\" as (select distinct \\"asset_id\\" from (select \\"t\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t\\" where \\"t\\".\\"asset_id\\" = '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' or \\"t\\".\\"ticker\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' union all select \\"t2\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets_metadata\\" as \\"t2\\" where \\"t2\\".\\"asset_name\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' union all select \\"t3\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t3\\" where \\"t3\\".\\"asset_name\\" ilike '7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj' or to_tsvector('simple', t3.asset_name) @@ to_tsquery('7FJhS4wyEKqsp77VCMfCZWKLSMuy1TWskYAyZ28amWFj:*')) as \\"a\\") select \\"t\\".\\"first_price\\", \\"t\\".\\"last_price\\", \\"t\\".\\"volume\\", \\"t\\".\\"quote_volume\\", \\"t\\".\\"high\\", \\"t\\".\\"low\\", \\"t\\".\\"weighted_average_price\\", \\"t\\".\\"txs_count\\", \\"t\\".\\"volume_waves\\", \\"t\\".\\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" from \\"pairs\\" as \\"t\\" inner join \\"assets_cte\\" as \\"amount_cte\\" on \\"amount_cte\\".\\"asset_id\\" = \\"t\\".\\"amount_asset_id\\" inner join \\"assets_cte\\" as \\"price_cte\\" on \\"price_cte\\".\\"asset_id\\" = \\"t\\".\\"amount_asset_id\\" where \\"matcher_address\\" = '' order by volume_waves desc NULLS LAST limit 10"`;
10
10
11
-
exports[`sql query from pairs should search pairs for one asset exactly 2`] = `"with \\"assets_cte\\" as (select distinct \\"asset_id\\" from (select \\"t\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t\\" where \\"t\\".\\"asset_id\\" = E'¯\\\\\\\\_(ツ)_/¯' or \\"t\\".\\"ticker\\" ilike E'¯\\\\\\\\_(ツ)_/¯' union all select \\"t2\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets_metadata\\" as \\"t2\\" where \\"t2\\".\\"asset_name\\" ilike E'¯\\\\\\\\_(ツ)_/¯' union all select \\"t3\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t3\\" where \\"t3\\".\\"asset_name\\" ilike E'¯\\\\\\\\_(ツ)_/¯') as \\"a\\") select \\"t\\".\\"first_price\\", \\"t\\".\\"last_price\\", \\"t\\".\\"volume\\", \\"t\\".\\"quote_volume\\", \\"t\\".\\"high\\", \\"t\\".\\"low\\", \\"t\\".\\"weighted_average_price\\", \\"t\\".\\"txs_count\\", \\"t\\".\\"volume_waves\\", \\"t\\".\\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" from \\"pairs\\" as \\"t\\" where \\"matcher_address\\" = '' order by volume_waves desc NULLS LAST limit 10"`;
11
+
exports[`sql query from pairs should search pairs for one asset exactly 2`] = `"with \\"assets_cte\\" as (select distinct \\"asset_id\\" from (select \\"t\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t\\" where \\"t\\".\\"asset_id\\" = E'¯\\\\\\\\_(ツ)_/¯' or \\"t\\".\\"ticker\\" ilike E'¯\\\\\\\\_(ツ)_/¯' union all select \\"t2\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets_metadata\\" as \\"t2\\" where \\"t2\\".\\"asset_name\\" ilike E'¯\\\\\\\\_(ツ)_/¯' union all select \\"t3\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"t3\\" where \\"t3\\".\\"asset_name\\" ilike E'¯\\\\\\\\_(ツ)_/¯') as \\"a\\") select \\"t\\".\\"first_price\\", \\"t\\".\\"last_price\\", \\"t\\".\\"volume\\", \\"t\\".\\"quote_volume\\", \\"t\\".\\"high\\", \\"t\\".\\"low\\", \\"t\\".\\"weighted_average_price\\", \\"t\\".\\"txs_count\\", \\"t\\".\\"volume_waves\\", \\"t\\".\\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" from \\"pairs\\" as \\"t\\" inner join \\"assets_cte\\" as \\"amount_cte\\" on \\"amount_cte\\".\\"asset_id\\" = \\"t\\".\\"amount_asset_id\\" inner join \\"assets_cte\\" as \\"price_cte\\" on \\"price_cte\\".\\"asset_id\\" = \\"t\\".\\"amount_asset_id\\" where \\"matcher_address\\" = '' order by volume_waves desc NULLS LAST limit 10"`;
12
12
13
13
exports[`sql query from pairs should search pairs for two assets (amount and price) 1`] = `"with \\"assets_cte\\" as (select \\"t1\\".\\"asset_id\\" as \\"amount_asset_id\\", \\"t2\\".\\"asset_id\\" as \\"price_asset_id\\" from (select distinct \\"asset_id\\" from (select \\"a\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"a\\" where \\"a\\".\\"asset_id\\" = 'BTC' or \\"a\\".\\"ticker\\" ilike 'BTC%' union all select \\"a2\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets_metadata\\" as \\"a2\\" where \\"a2\\".\\"asset_name\\" ilike 'BTC%' union all select \\"a3\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"a3\\" where \\"a3\\".\\"asset_name\\" ilike 'BTC%' or to_tsvector('simple', a3.asset_name) @@ to_tsquery('BTC:*')) as \\"a\\") as \\"t1\\" cross join (select distinct \\"asset_id\\" from (select \\"p\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"p\\" where \\"p\\".\\"asset_id\\" = 'WAVES' or \\"p\\".\\"ticker\\" ilike 'WAVES%' union all select \\"p2\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets_metadata\\" as \\"p2\\" where \\"p2\\".\\"asset_name\\" ilike 'WAVES%' union all select \\"p3\\".\\"asset_id\\" as \\"asset_id\\" from \\"assets\\" as \\"p3\\" where \\"p3\\".\\"asset_name\\" ilike 'WAVES%' or to_tsvector('simple', p3.asset_name) @@ to_tsquery('WAVES:*')) as \\"a\\") as \\"t2\\") select \\"t\\".\\"first_price\\", \\"t\\".\\"last_price\\", \\"t\\".\\"volume\\", \\"t\\".\\"quote_volume\\", \\"t\\".\\"high\\", \\"t\\".\\"low\\", \\"t\\".\\"weighted_average_price\\", \\"t\\".\\"txs_count\\", \\"t\\".\\"volume_waves\\", \\"t\\".\\"amount_asset_id\\", \\"t\\".\\"price_asset_id\\" from \\"pairs\\" as \\"t\\" inner join \\"assets_cte\\" as \\"direct_cte\\" on \\"direct_cte\\".\\"amount_asset_id\\" = \\"t\\".\\"amount_asset_id\\" and \\"direct_cte\\".\\"price_asset_id\\" = \\"t\\".\\"price_asset_id\\" where \\"matcher_address\\" = '' union all select \\"t1\\".\\"first_price\\", \\"t1\\".\\"last_price\\", \\"t1\\".\\"volume\\", \\"t1\\".\\"quote_volume\\", \\"t1\\".\\"high\\", \\"t1\\".\\"low\\", \\"t1\\".\\"weighted_average_price\\", \\"t1\\".\\"txs_count\\", \\"t1\\".\\"volume_waves\\", \\"t1\\".\\"amount_asset_id\\", \\"t1\\".\\"price_asset_id\\" from \\"pairs\\" as \\"t1\\" inner join \\"assets_cte\\" as \\"reverse_cte\\" on \\"reverse_cte\\".\\"amount_asset_id\\" = \\"t1\\".\\"price_asset_id\\" and \\"reverse_cte\\".\\"price_asset_id\\" = \\"t1\\".\\"amount_asset_id\\" where \\"matcher_address\\" = '' order by volume_waves desc NULLS LAST limit 10"`;
0 commit comments