-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(import): move import count to statistics (#3235)
* feat(import): move import count to statistics * feat(import) : add migration to drop import_count * feat(migration): modify revision to include import_count transfer data to statistics + fix notification template revision * fix(test): impact the deplacement of `import_count` into `TImports.statistics` * feat(import,synthese): remove unused value computation + increase timeout for forntend test
- Loading branch information
1 parent
615eb73
commit bfc16e2
Showing
14 changed files
with
611 additions
and
564 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
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
66 changes: 66 additions & 0 deletions
66
backend/geonature/migrations/versions/7b6a578eccd7_drop_import_count_column.py
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,66 @@ | ||
"""drop import_count column | ||
Revision ID: 7b6a578eccd7 | ||
Revises: c49474d2f1f7 | ||
Create Date: 2024-10-18 16:24:44.145501 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7b6a578eccd7" | ||
down_revision = "c49474d2f1f7" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.execute( | ||
""" | ||
UPDATE gn_imports.t_imports | ||
SET statistics = statistics::jsonb || jsonb_build_object('import_count', import_count); | ||
""" | ||
) | ||
op.drop_column( | ||
schema="gn_imports", | ||
table_name="t_imports", | ||
column_name="import_count", | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.add_column( | ||
schema="gn_imports", | ||
table_name="t_imports", | ||
column=sa.Column( | ||
"import_count", | ||
sa.Integer, | ||
), | ||
) | ||
|
||
op.execute( | ||
""" | ||
WITH count_ AS ( | ||
SELECT | ||
id_import as id_import, | ||
(statistics->>'import_count')::integer as import_count | ||
FROM | ||
gn_imports.t_imports | ||
WHERE | ||
statistics->>'import_count' IS NOT NULL | ||
) | ||
UPDATE gn_imports.t_imports as GN | ||
SET import_count = count_.import_count | ||
FROM count_ | ||
where GN.id_import = count_.id_import; | ||
""" | ||
) | ||
op.execute( | ||
""" | ||
UPDATE gn_imports.t_imports as GN | ||
SET statistics = statistics::jsonb #- '{import_count}'; | ||
""" | ||
) |
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 |
---|---|---|
|
@@ -5,4 +5,4 @@ export const VIEWPORTS = [ | |
}, | ||
]; | ||
|
||
export const TIMEOUT_WAIT = 1000; | ||
export const TIMEOUT_WAIT = 2000; |
Oops, something went wrong.