Skip to content

Commit bb8d102

Browse files
authored
Merge pull request #17 from dipdup-io/GO-75-add-comments-to-views
2 parents 32ad81f + 7292d53 commit bb8d102

File tree

4 files changed

+70
-20
lines changed

4 files changed

+70
-20
lines changed

.run/Run testnet.run.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<node-interpreter value="project" />
2626
<envs />
2727
</option>
28+
<option name="LaunchBrowser.Before.Run" url="http://127.0.0.1:22000/console" />
2829
</method>
2930
</configuration>
3031
</component>

cmd/mempool/views/dipdup_head_status.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ SELECT
77
END AS status,
88
created_at,
99
updated_at
10-
FROM
11-
dipdup_state;
10+
FROM dipdup_state;
11+
12+
comment on column dipdup_head_status.index_name is 'Name of the index.';
13+
comment on column dipdup_head_status.status is 'Status of head ("OK" or "OUTDATED" if relevance of head is more than three minutes behind)';
14+
comment on column dipdup_head_status.created_at is 'Date of creation in seconds since UNIX epoch.';
15+
comment on column dipdup_head_status.updated_at is 'Date of last update in seconds since UNIX epoch.';
Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
create or replace view mutez_per_gas_unit as
2-
select gas.waiting_levels , max(mutez_per_gas_unit), min(mutez_per_gas_unit), avg(mutez_per_gas_unit) as avg, count(mutez_per_gas_unit), percentile_disc(0.5) within group (order by gas.mutez_per_gas_unit) as median from (
3-
select
4-
(level_in_chain - level_in_mempool) as waiting_levels,
5-
((total_fee - 100 - 150 * 1)::float / total_gas_used) as mutez_per_gas_unit
6-
from gas_stats gs where level_in_chain > 0 and level_in_mempool > 0 and total_gas_used > 0
7-
) as gas
8-
group by gas.waiting_levels;
2+
select gas.waiting_levels,
3+
max(mutez_per_gas_unit),
4+
min(mutez_per_gas_unit),
5+
avg(mutez_per_gas_unit) as avg,
6+
count(mutez_per_gas_unit),
7+
percentile_disc(0.5) within group (order by gas.mutez_per_gas_unit) as median
8+
from (
9+
select
10+
(level_in_chain - level_in_mempool) as waiting_levels,
11+
((total_fee - 100 - 150 * 1)::float / total_gas_used) as mutez_per_gas_unit
12+
from gas_stats gs
13+
where level_in_chain > 0
14+
and level_in_mempool > 0
15+
and total_gas_used > 0
16+
) as gas
17+
group by gas.waiting_levels;
18+
19+
comment on view mutez_per_gas_unit is 'Statistics for micro tez per gas unit.';
20+
comment on column mutez_per_gas_unit.waiting_levels is 'Difference between level in chain and level in mempool.';
21+
comment on column mutez_per_gas_unit.max is 'Maximum price for gas unit.';
22+
comment on column mutez_per_gas_unit.min is 'Minimum price for gas unit.';
23+
comment on column mutez_per_gas_unit.avg is 'Average price for gas unit.';
24+
comment on column mutez_per_gas_unit.count is 'Count of prices for gas unit.';
25+
comment on column mutez_per_gas_unit.median is 'Percentile (50%) of price for gas unit.';
Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
11
create or replace view operation_groups as
2-
select network, hash, max(status) as status, max(source) as source, max(expiration_level) as expiration_level, max(level) as level, max(branch) as branch, sum(fee) as fee, max(counter) as max_counter, sum(storage_limit) as storage_limit, sum(gas_limit) as gas_limit, count(*) as num_contents, min(created_at) as created_at from
3-
(
4-
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from "transactions"
5-
union all
6-
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from delegations
7-
union all
8-
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from originations
9-
union all
10-
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from reveals
11-
) as foo
12-
group by network, hash;
2+
select network,
3+
hash,
4+
max(status) as status,
5+
max(source) as source,
6+
max(expiration_level) as expiration_level,
7+
max(level) as level,
8+
max(branch) as branch,
9+
sum(fee) as fee,
10+
max(counter) as max_counter,
11+
sum(storage_limit) as storage_limit,
12+
sum(gas_limit) as gas_limit,
13+
count(*) as num_contents,
14+
min(created_at) as created_at
15+
from
16+
(
17+
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from "transactions"
18+
union all
19+
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from delegations
20+
union all
21+
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from originations
22+
union all
23+
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from reveals
24+
) as foo
25+
group by network, hash;
26+
27+
comment on view operation_groups is 'Statistics per operations (transactions, delegations, originations, reveals) grouped by network and hash.';
28+
comment on column operation_groups.network is 'Network of the group.';
29+
comment on column operation_groups.hash is 'Hash of the operation group.';
30+
comment on column operation_groups.status is 'Status (max) of the operation group.';
31+
comment on column operation_groups.source is 'Source (max) of the operation group.';
32+
comment on column operation_groups.expiration_level is 'Expiration (max) level of the operation group.';
33+
comment on column operation_groups.level is 'Level (max) of the operation group.';
34+
comment on column operation_groups.branch is 'Branch (max) of the operation group.';
35+
comment on column operation_groups.fee is 'Sum of the fee of the operation group.';
36+
comment on column operation_groups.max_counter is 'Maximum counter of the operation group.';
37+
comment on column operation_groups.storage_limit is 'Sum of the storage limit of the operation group.';
38+
comment on column operation_groups.gas_limit is 'Sum of the gas limit of the operation group.';
39+
comment on column operation_groups.num_contents is 'Number of operations in group.';
40+
comment on column operation_groups.created_at is 'Date of fist operation creation in seconds since UNIX epoch.'

0 commit comments

Comments
 (0)