-
Notifications
You must be signed in to change notification settings - Fork 0
feat(int): show settings and logs and add button to manually run task #21
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
Changes from all commits
65fcb02
a60df03
50f75cc
6fee11b
aadb641
0de2c53
1a835b2
b58a830
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,14 @@ | ||
| use std::collections::HashMap; | ||
|
|
||
| use serde_json::json; | ||
| use uuid::Uuid; | ||
|
|
||
| use crate::{ | ||
| errors::AppResult, | ||
| models::{ActionKind, TagAssignment, TargetKind}, | ||
| integrations::MANIFESTS, | ||
| models::{ | ||
| ActionKind, IntegrationTaskLogEntry, IntegrationTaskRun, System, TagAssignment, TargetKind, | ||
| }, | ||
| services::audit_logs, | ||
| }; | ||
|
|
||
|
|
@@ -92,3 +98,90 @@ where | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| pub async fn list_integrations<'x, X>(db: X) -> AppResult<Vec<System>> | ||
| where | ||
| X: sqlx::Executor<'x, Database = sqlx::Postgres>, | ||
| { | ||
| let integration_ids: Vec<String> = MANIFESTS | ||
| .iter() | ||
| .map(|integration| integration.id.to_owned()) | ||
| .collect(); | ||
|
|
||
| let integrations = sqlx::query_as( | ||
| "SELECT name, description | ||
| FROM systems | ||
| WHERE system_id IN (SELECT UNNEST($1::TEXT[])) | ||
| ORDER BY id", | ||
| ) | ||
| .bind(integration_ids) | ||
| .fetch_all(db) | ||
| .await?; | ||
|
|
||
| Ok(integrations) | ||
| } | ||
|
|
||
| pub async fn list_settings<'x, X>( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't include in this listing, or (best) don't show value for settings marked |
||
| integration_id: &str, | ||
| db: X, | ||
| ) -> AppResult<HashMap<String, serde_json::Value>> | ||
| where | ||
| X: sqlx::Executor<'x, Database = sqlx::Postgres>, | ||
| { | ||
| let settings: HashMap<String, serde_json::Value> = sqlx::query_as( | ||
| "SELECT setting_id, setting_value | ||
| FROM integration_settings | ||
| WHERE integration_id = $1 | ||
| ORDER BY setting_id", | ||
| ) | ||
| .bind(integration_id) | ||
| .fetch_all(db) | ||
| .await? | ||
| .into_iter() | ||
| .collect(); | ||
|
|
||
| Ok(settings) | ||
| } | ||
|
|
||
| pub async fn list_runs<'x, X>(integration_id: &str, db: X) -> AppResult<Vec<IntegrationTaskRun>> | ||
| where | ||
| X: sqlx::Executor<'x, Database = sqlx::Postgres>, | ||
| { | ||
| let runs = sqlx::query_as( | ||
| "SELECT | ||
| run_id, | ||
| task_id, | ||
| start_stamp, | ||
| end_stamp, | ||
| succeeded | ||
| FROM integration_task_runs | ||
| WHERE integration_id = $1 | ||
| ORDER BY start_stamp ASC", | ||
| ) | ||
| .bind(integration_id) | ||
| .fetch_all(db) | ||
| .await? | ||
| .into_iter() | ||
| .collect(); | ||
|
|
||
| Ok(runs) | ||
| } | ||
|
|
||
| pub async fn list_logs<'x, X>(run_id: Uuid, db: X) -> AppResult<Vec<IntegrationTaskLogEntry>> | ||
| where | ||
| X: sqlx::Executor<'x, Database = sqlx::Postgres>, | ||
| { | ||
| let logs = sqlx::query_as( | ||
| "SELECT stamp, kind, message | ||
| FROM integration_task_logs | ||
| WHERE run_id = $1 | ||
| ORDER BY stamp ASC", | ||
| ) | ||
| .bind(run_id) | ||
| .fetch_all(db) | ||
| .await? | ||
| .into_iter() | ||
| .collect(); | ||
|
|
||
| Ok(logs) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort alphabetically