Skip to content

Commit

Permalink
Merge pull request #17 from dipdup-io/GO-75-add-comments-to-views
Browse files Browse the repository at this point in the history
  • Loading branch information
vvuwei authored Jun 30, 2023
2 parents 32ad81f + 7292d53 commit bb8d102
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 20 deletions.
1 change: 1 addition & 0 deletions .run/Run testnet.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<node-interpreter value="project" />
<envs />
</option>
<option name="LaunchBrowser.Before.Run" url="http://127.0.0.1:22000/console" />
</method>
</configuration>
</component>
8 changes: 6 additions & 2 deletions cmd/mempool/views/dipdup_head_status.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ SELECT
END AS status,
created_at,
updated_at
FROM
dipdup_state;
FROM dipdup_state;

comment on column dipdup_head_status.index_name is 'Name of the index.';
comment on column dipdup_head_status.status is 'Status of head ("OK" or "OUTDATED" if relevance of head is more than three minutes behind)';
comment on column dipdup_head_status.created_at is 'Date of creation in seconds since UNIX epoch.';
comment on column dipdup_head_status.updated_at is 'Date of last update in seconds since UNIX epoch.';
31 changes: 24 additions & 7 deletions cmd/mempool/views/mutez_per_gas_unit.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
create or replace view mutez_per_gas_unit as
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 (
select
(level_in_chain - level_in_mempool) as waiting_levels,
((total_fee - 100 - 150 * 1)::float / total_gas_used) as mutez_per_gas_unit
from gas_stats gs where level_in_chain > 0 and level_in_mempool > 0 and total_gas_used > 0
) as gas
group by gas.waiting_levels;
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 (
select
(level_in_chain - level_in_mempool) as waiting_levels,
((total_fee - 100 - 150 * 1)::float / total_gas_used) as mutez_per_gas_unit
from gas_stats gs
where level_in_chain > 0
and level_in_mempool > 0
and total_gas_used > 0
) as gas
group by gas.waiting_levels;

comment on view mutez_per_gas_unit is 'Statistics for micro tez per gas unit.';
comment on column mutez_per_gas_unit.waiting_levels is 'Difference between level in chain and level in mempool.';
comment on column mutez_per_gas_unit.max is 'Maximum price for gas unit.';
comment on column mutez_per_gas_unit.min is 'Minimum price for gas unit.';
comment on column mutez_per_gas_unit.avg is 'Average price for gas unit.';
comment on column mutez_per_gas_unit.count is 'Count of prices for gas unit.';
comment on column mutez_per_gas_unit.median is 'Percentile (50%) of price for gas unit.';
50 changes: 39 additions & 11 deletions cmd/mempool/views/operation_groups.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
create or replace view operation_groups as
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
(
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from "transactions"
union all
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from delegations
union all
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from originations
union all
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from reveals
) as foo
group by network, hash;
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
(
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from "transactions"
union all
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from delegations
union all
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from originations
union all
select network, status, source, expiration_level, level, branch, hash, fee, counter, storage_limit, gas_limit, created_at from reveals
) as foo
group by network, hash;

comment on view operation_groups is 'Statistics per operations (transactions, delegations, originations, reveals) grouped by network and hash.';
comment on column operation_groups.network is 'Network of the group.';
comment on column operation_groups.hash is 'Hash of the operation group.';
comment on column operation_groups.status is 'Status (max) of the operation group.';
comment on column operation_groups.source is 'Source (max) of the operation group.';
comment on column operation_groups.expiration_level is 'Expiration (max) level of the operation group.';
comment on column operation_groups.level is 'Level (max) of the operation group.';
comment on column operation_groups.branch is 'Branch (max) of the operation group.';
comment on column operation_groups.fee is 'Sum of the fee of the operation group.';
comment on column operation_groups.max_counter is 'Maximum counter of the operation group.';
comment on column operation_groups.storage_limit is 'Sum of the storage limit of the operation group.';
comment on column operation_groups.gas_limit is 'Sum of the gas limit of the operation group.';
comment on column operation_groups.num_contents is 'Number of operations in group.';
comment on column operation_groups.created_at is 'Date of fist operation creation in seconds since UNIX epoch.'

0 comments on commit bb8d102

Please sign in to comment.