-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store integration trigger result (#1247)
* feat(migrations): add column for trigger result * feat(migrations): add default value to trigger result for integrations * feat(backend): adapt to new db schema * feat(backend): store integration trigger result * feat(migrations): drop the last trigger on column * feat(backend): change names of attributes * feat(services/integration): handle when the sync itself fails * feat(services/integration): store only 20 elements in the queue * Merge branch 'main' into issue-1232 * feat(services/integration): use more efficient structure for trigger results * chore(frontend): remove ref to invalid integration column * chore(frontend): add separator between first row elements * chore(frontend): add empty fragment * fix(frontend): do not show paused if it is not * feat(frontend): add btn to show integration trigger result * refactor(frontend): change name of var * feat(frontend): add modal for trigger result display * feat(frontend): display integration logs in a table * chore(frontend): remove useless text in header * docs: add information about automatic disabling of integrations * feat(migrations): add column for last finished at to integration table * feat(backend): store the last finished at date for integration * feat(frontend): display last finished on * feat(migrations): set the last triggered at date correctly for integrations * fix(frontend): change the font sizes to be consistent * ci: Run CI * chore(frontend): remove useless map * refactor(services/integration): common function to select integrations * fix(migrations): handle cases when integration has never been triggered * chore(services/integration): order by created on when selecting integrations * feat(services/misc): add fn to mark integrations as disabled * feat(backend): add new notification type * feat(frontend): allow disabling new integration * feat(services/misc): complete implementation of automatically disabling integrations * ci: Run CI * refactor(services/misc): do not declare separate integrations
- Loading branch information
Showing
15 changed files
with
395 additions
and
164 deletions.
There are no files selected for viewing
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
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,65 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
let db = manager.get_connection(); | ||
if !manager.has_column("integration", "trigger_result").await? { | ||
db.execute_unprepared( | ||
r#" | ||
ALTER TABLE "integration" ADD COLUMN "trigger_result" JSONB NOT NULL DEFAULT '[]'::JSONB; | ||
UPDATE "integration" i SET "trigger_result" = JSONB_BUILD_ARRAY(JSONB_BUILD_OBJECT('finished_at', i."last_triggered_on")) | ||
WHERE i."last_triggered_on" IS NOT NULL; | ||
"#, | ||
) | ||
.await?; | ||
} | ||
if !manager | ||
.has_column("integration", "last_finished_at") | ||
.await? | ||
{ | ||
db.execute_unprepared( | ||
r#" | ||
ALTER TABLE "integration" ADD COLUMN "last_finished_at" TIMESTAMPTZ; | ||
UPDATE "integration" i SET "last_finished_at" = i."last_triggered_on" | ||
WHERE i."last_triggered_on" IS NOT NULL; | ||
"#, | ||
) | ||
.await?; | ||
} | ||
if manager | ||
.has_column("integration", "last_triggered_on") | ||
.await? | ||
{ | ||
db.execute_unprepared(r#"ALTER TABLE "integration" DROP COLUMN "last_triggered_on";"#) | ||
.await?; | ||
} | ||
db.execute_unprepared( | ||
r#" | ||
UPDATE | ||
"user" | ||
SET | ||
preferences = JSONB_SET( | ||
preferences, | ||
'{notifications,to_send}', | ||
(preferences -> 'notifications' -> 'to_send') || '"IntegrationDisabledDueToTooManyErrors"' | ||
) | ||
where | ||
NOT ( | ||
preferences -> 'notifications' -> 'to_send' ? 'IntegrationDisabledDueToTooManyErrors' | ||
); | ||
"#, | ||
) | ||
.await?; | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { | ||
Ok(()) | ||
} | ||
} |
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
Oops, something went wrong.