-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:Concordium/concordium-scan into lma…
…/release/github_actions
- Loading branch information
Showing
122 changed files
with
7,457 additions
and
6,929 deletions.
There are no files selected for viewing
6 changes: 5 additions & 1 deletion
6
.github/workflows/check-format-build.yml → .github/workflows/backend-checks.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
.github/workflows/ci.yml → .github/workflows/backend-net-checks.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Check frontend | ||
|
||
on: | ||
push: | ||
branches: main | ||
paths: | ||
- frontend/** | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
branches: [ main ] | ||
paths: | ||
- frontend/** | ||
|
||
env: | ||
NODE_VERSION: "18.18.2" | ||
|
||
jobs: | ||
checks: | ||
name: Formatting and types | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
cache: 'yarn' | ||
cache-dependency-path: frontend/yarn.lock | ||
- name: Install deps | ||
working-directory: frontend | ||
run: yarn install --frozen-lockfile --immutable | ||
- name: Check formatting | ||
working-directory: frontend | ||
run: yarn run formatcheck | ||
- name: Check types | ||
working-directory: frontend | ||
run: yarn run typecheck | ||
# - name: Linting | ||
# working-directory: frontend | ||
# run: yarn run lintcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Publish frontend docker image on DockerHub | ||
|
||
on: | ||
push: | ||
tags: | ||
- frontend/* | ||
|
||
jobs: | ||
publish-docker-image: | ||
runs-on: ubuntu-latest | ||
environment: release | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
flavor: latest=false | ||
images: concordium/ccdscan-frontend | ||
tags: type=match,pattern=frontend/(.*),group=1 | ||
- name: Ensure tag matches version in package.json | ||
run: | | ||
EXPECTED=$(jq -r .version frontend/package.json) | ||
EXTRACTED="${{ steps.meta.outputs.version }}" | ||
if [ "$EXPECTED" = "$EXTRACTED" ]; then | ||
printf "Extracted version matches the version in package.json ($EXTRACTED).\n" | ||
exit 0 | ||
else | ||
printf "ERROR: Extracted version does not match the version in package.json. \nExtracted: '$EXTRACTED'\nExpected: '$EXPECTED'\n" | ||
exit 1 | ||
fi | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: concordium | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ./frontend | ||
file: ./frontend/Dockerfile | ||
push: true | ||
platforms: linux/amd64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
20 changes: 20 additions & 0 deletions
20
...nd-rust/.sqlx/query-163cc788cf5c4fd22a1f8e0289ad322fa7d92a7dd503a03a517622f2942c4d60.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
...nd-rust/.sqlx/query-792aeb42f25e1f70758407b469945187b00c166757ad7f9324abf3f58ac1e821.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...nd-rust/.sqlx/query-d6bccf668d544b1649962a5f0fb358bada7fbdbb4f78de19cc2ab8d0be5a83d5.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
use std::sync::Arc; | ||
|
||
use async_graphql::{Context, Object, SimpleObject}; | ||
use sqlx::postgres::types::PgInterval; | ||
|
||
use super::{get_pool, ApiError, ApiResult, DateTime, MetricsPeriod, TimeSpan}; | ||
|
||
#[derive(SimpleObject)] | ||
struct AccountMetrics { | ||
/// Total number of accounts created (all time). | ||
last_cumulative_accounts_created: i64, | ||
|
||
/// Total number of accounts created in requested period. | ||
accounts_created: i64, | ||
|
||
buckets: AccountMetricsBuckets, | ||
} | ||
|
||
#[derive(SimpleObject)] | ||
struct AccountMetricsBuckets { | ||
/// The width (time interval) of each bucket. | ||
bucket_width: TimeSpan, | ||
|
||
/// Start of the bucket time period. Intended x-axis value. | ||
#[graphql(name = "x_Time")] | ||
x_time: Vec<DateTime>, | ||
|
||
/// Total number of accounts created (all time) at the end of the bucket | ||
/// period. Intended y-axis value. | ||
#[graphql(name = "y_LastCumulativeAccountsCreated")] | ||
y_last_cumulative_accounts_created: Vec<i64>, | ||
|
||
/// Number of accounts created within bucket time period. Intended y-axis | ||
/// value. | ||
#[graphql(name = "y_AccountsCreated")] | ||
y_accounts_created: Vec<i64>, | ||
} | ||
|
||
#[derive(Default)] | ||
pub(crate) struct AccountMetricsQuery; | ||
|
||
#[Object] | ||
impl AccountMetricsQuery { | ||
async fn account_metrics( | ||
&self, | ||
ctx: &Context<'_>, | ||
period: MetricsPeriod, | ||
) -> ApiResult<AccountMetrics> { | ||
let pool = get_pool(ctx)?; | ||
|
||
let last_cumulative_accounts_created = | ||
sqlx::query_scalar!("SELECT COALESCE(MAX(index), 0) FROM accounts") | ||
.fetch_one(pool) | ||
.await? | ||
.expect("coalesced"); | ||
|
||
// The full period interval, e.g. 7 days. | ||
let period_interval: PgInterval = period | ||
.as_duration() | ||
.try_into() | ||
.map_err(|e| ApiError::DurationOutOfRange(Arc::new(e)))?; | ||
|
||
let cumulative_accounts_created_before_period = sqlx::query_scalar!( | ||
"SELECT COALESCE(MAX(index), 0) | ||
FROM accounts | ||
LEFT JOIN blocks ON created_block = height | ||
WHERE slot_time < (now() - $1::interval)", | ||
period_interval, | ||
) | ||
.fetch_one(pool) | ||
.await? | ||
.expect("coalesced"); | ||
|
||
let accounts_created = | ||
last_cumulative_accounts_created - cumulative_accounts_created_before_period; | ||
|
||
let bucket_width = period.bucket_width(); | ||
|
||
// The bucket interval, e.g. 6 hours. | ||
let bucket_interval: PgInterval = | ||
bucket_width.try_into().map_err(|err| ApiError::DurationOutOfRange(Arc::new(err)))?; | ||
|
||
let rows = sqlx::query_file!( | ||
"src/graphql_api/account_metrics.sql", | ||
period_interval, | ||
bucket_interval, | ||
) | ||
.fetch_all(pool) | ||
.await?; | ||
|
||
let x_time = rows | ||
.iter() | ||
.map(|r| r.bucket_time.expect("generated by generate_series so never null")) | ||
.collect(); | ||
let y_last_cumulative_accounts_created = | ||
rows.iter().map(|r| r.end_index.expect("coalesced")).collect(); | ||
let y_accounts_created = rows | ||
.iter() | ||
.map(|r| r.end_index.expect("coalesced") - r.start_index.expect("coalesced")) | ||
.collect(); | ||
|
||
Ok(AccountMetrics { | ||
last_cumulative_accounts_created, | ||
accounts_created, | ||
buckets: AccountMetricsBuckets { | ||
bucket_width: TimeSpan(bucket_width), | ||
x_time, | ||
y_last_cumulative_accounts_created, | ||
y_accounts_created, | ||
}, | ||
}) | ||
} | ||
} |
Oops, something went wrong.