-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from constata-eu/initial_asami_explorer
Initial asami explorer
- Loading branch information
Showing
64 changed files
with
2,197 additions
and
343 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
api/migrations/20241213120000_add_indexed_columns_for_explorer.sql
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,25 @@ | ||
ALTER TABLE accounts ADD COLUMN force_hydrate BOOLEAN NOT NULL DEFAULT FALSE; | ||
ALTER TABLE accounts ADD COLUMN total_collabs INT4 NOT NULL DEFAULT 0; | ||
ALTER TABLE accounts ADD COLUMN total_collab_rewards VARCHAR NOT NULL DEFAULT '0x0'; | ||
ALTER TABLE accounts ADD COLUMN total_campaigns INT4 NOT NULL DEFAULT 0; | ||
ALTER TABLE accounts ADD COLUMN total_collabs_received INT4 NOT NULL DEFAULT 0; | ||
ALTER TABLE accounts ADD COLUMN total_spent VARCHAR NOT NULL DEFAULT '0x0'; | ||
ALTER TABLE accounts ADD COLUMN unclaimed_asami_balance VARCHAR NOT NULL DEFAULT '0x0'; | ||
ALTER TABLE accounts ADD COLUMN unclaimed_doc_balance VARCHAR NOT NULL DEFAULT '0x0'; | ||
ALTER TABLE accounts ADD COLUMN asami_balance VARCHAR NOT NULL DEFAULT '0x0'; | ||
ALTER TABLE accounts ADD COLUMN doc_balance VARCHAR NOT NULL DEFAULT '0x0'; | ||
ALTER TABLE accounts ADD COLUMN rbtc_balance VARCHAR NOT NULL DEFAULT '0x0'; | ||
ALTER TABLE accounts ADD COLUMN last_on_chain_sync TIMESTAMPTZ NOT NULL DEFAULT now(); | ||
|
||
ALTER TABLE handles ADD COLUMN force_hydrate BOOLEAN NOT NULL DEFAULT FALSE; | ||
ALTER TABLE handles ADD COLUMN total_collabs INT4 NOT NULL DEFAULT 0; | ||
ALTER TABLE handles ADD COLUMN total_collab_rewards VARCHAR NOT NULL DEFAULT '0x0'; | ||
|
||
ALTER TABLE campaigns ADD COLUMN force_hydrate BOOLEAN NOT NULL DEFAULT FALSE; | ||
ALTER TABLE campaigns ADD COLUMN total_collabs INT4 NOT NULL DEFAULT 0; | ||
ALTER TABLE campaigns ADD COLUMN total_spent VARCHAR NOT NULL DEFAULT '0x0'; | ||
ALTER TABLE campaigns ADD COLUMN total_budget VARCHAR NOT NULL DEFAULT '0x0'; | ||
|
||
UPDATE accounts SET force_hydrate = TRUE; | ||
UPDATE handles SET force_hydrate = TRUE; | ||
UPDATE campaigns SET force_hydrate = TRUE; |
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,69 @@ | ||
use super::{ | ||
models::{self, *}, | ||
*, | ||
}; | ||
|
||
#[derive(Debug, GraphQLObject, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
#[graphql(description = "An message logged for any part of the system")] | ||
pub struct AuditLogEntry { | ||
#[graphql(description = "Unique numeric identifier of this resource")] | ||
id: i32, | ||
severity: AuditLogSeverity, | ||
created_at: UtcDateTime, | ||
kind: String, | ||
subkind: String, | ||
context: String, | ||
loggable_type: Option<String>, | ||
loggable_id: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Clone, Default, GraphQLInputObject, serde::Serialize, serde::Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct AuditLogEntryFilter { | ||
ids: Option<Vec<i32>>, | ||
id_eq: Option<i32>, | ||
} | ||
|
||
#[rocket::async_trait] | ||
impl Showable<models::AuditLogEntry, AuditLogEntryFilter> for AuditLogEntry { | ||
fn sort_field_to_order_by(field: &str) -> Option<models::AuditLogEntryOrderBy> { | ||
match field { | ||
"id" => Some(AuditLogEntryOrderBy::Id), | ||
"created_at" => Some(AuditLogEntryOrderBy::CreatedAt), | ||
_ => None, | ||
} | ||
} | ||
|
||
fn filter_to_select(_context: &Context, filter: Option<AuditLogEntryFilter>) -> FieldResult<models::SelectAuditLogEntry> { | ||
if let Some(f) = filter { | ||
Ok(models::SelectAuditLogEntry { | ||
id_in: f.ids, | ||
id_eq: f.id_eq, | ||
..Default::default() | ||
}) | ||
} else { | ||
Ok(Default::default()) | ||
} | ||
} | ||
|
||
fn select_by_id(_context: &Context, id: i32) -> FieldResult<models::SelectAuditLogEntry> { | ||
Ok(models::SelectAuditLogEntry { | ||
id_eq: Some(id), | ||
..Default::default() | ||
}) | ||
} | ||
|
||
async fn db_to_graphql(_context: &Context, d: models::AuditLogEntry) -> AsamiResult<Self> { | ||
Ok(AuditLogEntry { | ||
id: d.attrs.id, | ||
severity: d.attrs.severity, | ||
created_at: d.attrs.created_at, | ||
kind: d.attrs.kind, | ||
subkind: d.attrs.subkind, | ||
context: d.attrs.context, | ||
loggable_type: d.attrs.loggable_type, | ||
loggable_id: d.attrs.loggable_id, | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.