Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

View table to calculate oracle script response time #2452

Merged
merged 7 commits into from
Aug 19, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Emitter & Flusher

- (impv) [\#2452](https://github.com/bandprotocol/bandchain/pull/2452) Implemented view table to calculate oracle script response time
- (impv) [\#2486](https://github.com/bandprotocol/bandchain/pull/2486) Implemented reporters table.
- (impv) [\#2475](https://github.com/bandprotocol/bandchain/pull/2475) Add related data source and oracle script table.
- (impv) [\#2450](https://github.com/bandprotocol/bandchain/pull/2450) Add request count 1day view table.
Expand Down
41 changes: 41 additions & 0 deletions flusher/flusher/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,44 @@ def init(chain_id, topic, db):
GROUP BY date;
"""
)
engine.execute(
"""CREATE VIEW oracle_script_statistic_last_1_day AS
SELECT
AVG(resolve_time-request_time) as response_time,
COUNT(*) as count,
oracle_scripts.id,
resolve_status
FROM oracle_scripts
JOIN requests ON oracle_scripts.id=requests.oracle_script_id
WHERE to_timestamp(requests.request_time) >= NOW() - '1 day'::INTERVAL
GROUP BY oracle_scripts.id, requests.resolve_status;
"""
)

engine.execute(
"""CREATE VIEW oracle_script_statistic_last_1_week AS
SELECT
AVG(resolve_time-request_time) as response_time,
COUNT(*) as count,
oracle_scripts.id,
resolve_status
FROM oracle_scripts
JOIN requests ON oracle_scripts.id=requests.oracle_script_id
WHERE to_timestamp(requests.request_time) >= NOW() - '1 week'::INTERVAL
GROUP BY oracle_scripts.id, requests.resolve_status;
"""
)

engine.execute(
"""CREATE VIEW oracle_script_statistic_last_1_month AS
SELECT
AVG(resolve_time-request_time) as response_time,
COUNT(*) as count,
oracle_scripts.id,
resolve_status
FROM oracle_scripts
JOIN requests ON oracle_scripts.id=requests.oracle_script_id
WHERE to_timestamp(requests.request_time) >= NOW() - '1 month'::INTERVAL
GROUP BY oracle_scripts.id, requests.resolve_status;
"""
)