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

[Extra/rest 2.5] Add stats for os and ds, Fix jail status #312

Merged
merged 6 commits into from
Jul 6, 2023

Conversation

RogerKSI
Copy link
Contributor

@RogerKSI RogerKSI commented Jun 19, 2023

Implementation details

  • Add last_request for Oracle script and data source.
  • Add stats for requests of each os and ds per day.
  • Add view to query last 1 day of number of requests of ds.
  • Fix jail status for unbonding case

SQL

ALTER TABLE oracle_scripts ADD last_request timestamp WITHOUT TIME ZONE;
ALTER TABLE data_sources ADD last_request timestamp WITHOUT TIME ZONE;

CREATE TABLE oracle_script_requests_per_days (
        date DATE NOT NULL, 
        oracle_script_id INTEGER NOT NULL, 
        count INTEGER NOT NULL, 
        PRIMARY KEY (date, oracle_script_id), 
        FOREIGN KEY(oracle_script_id) REFERENCES oracle_scripts (id)
)

CREATE TABLE data_source_requests_per_days (
        date DATE NOT NULL, 
        data_source_id INTEGER NOT NULL, 
        count INTEGER NOT NULL, 
        PRIMARY KEY (date, data_source_id), 
        FOREIGN KEY(data_source_id) REFERENCES data_sources (id)
)

CREATE VIEW data_source_statistic_last_1_day
AS
  SELECT data_sources.id,
         count(*) AS count
  FROM   data_sources
         join raw_requests
           ON data_sources.id = raw_requests.data_source_id
         join requests
           ON raw_requests.request_id  = requests.id
  WHERE  requests.request_time >= CAST(EXTRACT(epoch FROM NOW()) AS INT) - 86400
  GROUP  BY data_sources.id;

Please ensure the following requirements are met before submitting a pull request:

  • The pull request is targeted against the correct target branch
  • The pull request is linked to an issue with appropriate discussion and an accepted design OR is linked to a spec that describes the work.
  • The pull request includes a description of the implementation/work done in detail.
  • The pull request includes any and all appropriate unit/integration tests
  • You have added a relevant changelog entry to CHANGELOG_UNRELEASED.md
  • You have re-reviewed the files affected by the pull request (e.g. using the Files changed tab in the Github PR explorer)

@RogerKSI RogerKSI requested a review from satawatnack July 3, 2023 05:59
@RogerKSI RogerKSI changed the title [Extra/rest 2.5] Add stats request per os, Fix jail status [Extra/rest 2.5] Add stats for os and ds, Fix jail status Jul 5, 2023
@RogerKSI RogerKSI requested a review from colmazia July 5, 2023 15:09
Copy link
Contributor

@colmazia colmazia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add comments in the future

@colmazia colmazia merged commit 46fea12 into extra-rest/v2.5.x Jul 6, 2023
2 checks passed
@colmazia colmazia deleted the extra-rest-25-add-stats branch July 6, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants