-
Notifications
You must be signed in to change notification settings - Fork 0
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 #12 from Angel-Dijoux/angel/scrapt_onisep
[Refacto] Onisep calls in backend.
- Loading branch information
Showing
25 changed files
with
744 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": false, | ||
"editor.formatOnPaste": true, | ||
"[json]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[python]": { | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": true, | ||
"source.organizeImports": true | ||
} | ||
}, | ||
"python.formatting.provider": "black", | ||
"python.formatting.blackArgs": [ | ||
"--config", | ||
"${workspaceFolder}/pyproject.toml" | ||
], | ||
"python.analysis.extraPaths": ["backend_flask"], | ||
"python.analysis.autoImportCompletions": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
{ | ||
"editor.tabCompletion": "on", | ||
"diffEditor.codeLens": true, | ||
"python.analysis.typeCheckingMode": "basic" | ||
} | ||
"python.analysis.autoImportCompletions": 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
migrations/versions/16c8bc08a922_create_user_favori_table.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,100 @@ | ||
"""Delete and re-create favori table | ||
Revision ID: 16c8bc08a922 | ||
Revises: a3fe3092f50c | ||
Create Date: 2023-10-29 18:56:52.112998 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import mysql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "16c8bc08a922" | ||
down_revision = "a3fe3092f50c" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"user_favori", | ||
sa.Column("formation_id", sa.String(length=36), nullable=False), | ||
sa.Column("user_id", sa.Integer(), nullable=False), | ||
sa.Column("created_at", sa.DateTime(), nullable=False), | ||
sa.Column("updated_at", sa.DateTime(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["formation_id"], | ||
["formation.id"], | ||
ondelete="CASCADE", | ||
name="favori_formation_id_fk", | ||
), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], ["user.id"], ondelete="CASCADE", name="favori_user_id_fk" | ||
), | ||
sa.PrimaryKeyConstraint("formation_id", "user_id", name="favori_pk"), | ||
) | ||
op.create_index( | ||
op.f("ix_user_favori_formation_id"), | ||
"user_favori", | ||
["formation_id"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_user_favori_user_id"), "user_favori", ["user_id"], unique=False | ||
) | ||
|
||
op.execute( | ||
""" | ||
INSERT INTO user_favori (formation_id, user_id, created_at, updated_at) | ||
SELECT fr.id, f.request_user_id, f.created_at, f.updated_at | ||
FROM favori f | ||
JOIN formation fr ON f.code_nsf = fr.code_nsf | ||
AND f.sigle_type_formation = fr.type | ||
AND f.libelle_formation_principal = fr.libelle | ||
AND f.tutelle = fr.tutelle | ||
AND f.url_et_id_onisep = fr.url | ||
AND f.niveau_de_sortie_indicatif = fr.niveau_de_sortie | ||
AND f.duree = fr.duree | ||
AND f.created_at = fr.created_at | ||
AND f.updated_at = fr.updated_at; | ||
""" | ||
) | ||
|
||
op.drop_table("favori") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"favori", | ||
sa.Column("id", mysql.INTEGER(), autoincrement=True, nullable=False), | ||
sa.Column("code_nsf", mysql.TEXT(), nullable=True), | ||
sa.Column("sigle_type_formation", mysql.TEXT(), nullable=True), | ||
sa.Column("libelle_type_formation", mysql.TEXT(), nullable=True), | ||
sa.Column("libelle_formation_principal", mysql.TEXT(), nullable=True), | ||
sa.Column("sigle_formation", mysql.TEXT(), nullable=True), | ||
sa.Column("duree", mysql.TEXT(), nullable=True), | ||
sa.Column("niveau_de_sortie_indicatif", mysql.TEXT(), nullable=True), | ||
sa.Column("code_rncp", mysql.TEXT(), nullable=True), | ||
sa.Column("niveau_de_certification", mysql.TEXT(), nullable=True), | ||
sa.Column("libelle_niveau_de_certification", mysql.TEXT(), nullable=True), | ||
sa.Column("tutelle", mysql.TEXT(), nullable=True), | ||
sa.Column("url_et_id_onisep", mysql.TEXT(), nullable=False), | ||
sa.Column( | ||
"request_user_id", mysql.INTEGER(), autoincrement=False, nullable=True | ||
), | ||
sa.Column("created_at", mysql.DATETIME(), nullable=False), | ||
sa.Column("updated_at", mysql.DATETIME(), nullable=False), | ||
sa.ForeignKeyConstraint(["request_user_id"], ["user.id"], name="favori_ibfk_1"), | ||
sa.PrimaryKeyConstraint("id"), | ||
mysql_collate="utf8mb4_0900_ai_ci", | ||
mysql_default_charset="utf8mb4", | ||
mysql_engine="InnoDB", | ||
) | ||
op.drop_index(op.f("ix_user_favori_user_id"), table_name="user_favori") | ||
op.drop_index(op.f("ix_user_favori_formation_id"), table_name="user_favori") | ||
op.drop_table("user_favori") | ||
# ### end Alembic commands ### |
61 changes: 61 additions & 0 deletions
61
migrations/versions/a3fe3092f50c_create_formation_table.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,61 @@ | ||
"""Create formation table | ||
Revision ID: a3fe3092f50c | ||
Revises: 8ce7337ffbf4 | ||
Create Date: 2023-10-29 15:59:03.950861 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "a3fe3092f50c" | ||
down_revision = "8ce7337ffbf4" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"formation", | ||
sa.Column("id", sa.String(length=36), nullable=False), | ||
sa.Column("code_nsf", sa.Integer(), nullable=False), | ||
sa.Column("type", sa.String(length=120), nullable=False), | ||
sa.Column("libelle", sa.String(length=120), nullable=False), | ||
sa.Column("tutelle", sa.String(length=120), nullable=False), | ||
sa.Column("url", sa.String(length=255), nullable=False), | ||
sa.Column("domain", sa.String(length=255), nullable=False), | ||
sa.Column("niveau_de_sortie", sa.String(length=120), nullable=False), | ||
sa.Column("duree", sa.String(length=15), nullable=False), | ||
sa.Column("created_at", sa.DateTime(), nullable=False), | ||
sa.Column("updated_at", sa.DateTime(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("url"), | ||
) | ||
op.execute( | ||
""" | ||
INSERT INTO formation (id, code_nsf, type, libelle, tutelle, url, domain, niveau_de_sortie, duree, created_at, updated_at) | ||
SELECT | ||
UUID(), | ||
f.code_nsf, | ||
f.sigle_type_formation, | ||
f.libelle_formation_principal, | ||
f.tutelle, | ||
f.url_et_id_onisep, | ||
"NULL", | ||
f.niveau_de_sortie_indicatif, | ||
f.duree, | ||
f.created_at, | ||
f.updated_at | ||
FROM favori f; | ||
""" | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("formation") | ||
# ### end Alembic commands ### |
68 changes: 68 additions & 0 deletions
68
migrations/versions/ee56a7eaab4a_alter_formation_user_favori_tables.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,68 @@ | ||
"""Add UUID in formation table. | ||
Revision ID: ee56a7eaab4a | ||
Revises: 16c8bc08a922 | ||
Create Date: 2023-10-29 22:09:53.444244 | ||
""" | ||
from alembic import op | ||
from sqlalchemy.dialects import mysql | ||
|
||
from src.models.helpers.UUIDType import UUIDType | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "ee56a7eaab4a" | ||
down_revision = "16c8bc08a922" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
|
||
op.drop_constraint("favori_formation_id_fk", "user_favori", type_="foreignkey") | ||
|
||
op.alter_column( | ||
"formation", | ||
"id", | ||
existing_type=mysql.VARCHAR(length=36), | ||
type_=UUIDType(), | ||
existing_nullable=False, | ||
) | ||
op.alter_column( | ||
"user_favori", | ||
"formation_id", | ||
existing_type=mysql.VARCHAR(length=36), | ||
type_=UUIDType(), | ||
existing_nullable=False, | ||
) | ||
|
||
op.create_foreign_key( | ||
"favori_formation_id_fk", "user_favori", "formation", ["formation_id"], ["id"] | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint("favori_formation_id_fk", "user_favori", type_="foreignkey") | ||
|
||
op.alter_column( | ||
"user_favori", | ||
"formation_id", | ||
existing_type=UUIDType(), | ||
type_=mysql.VARCHAR(length=36), | ||
existing_nullable=False, | ||
) | ||
op.alter_column( | ||
"formation", | ||
"id", | ||
existing_type=UUIDType(), | ||
type_=mysql.VARCHAR(length=36), | ||
existing_nullable=False, | ||
) | ||
|
||
op.create_foreign_key( | ||
"favori_formation_id_fk", "user_favori", "formation", ["formation_id"], ["id"] | ||
) | ||
# ### end Alembic commands ### |
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,45 @@ | ||
[tool.isort] | ||
profile = "black" | ||
|
||
[tool.black] | ||
py36 = true | ||
include = '\.pyi?$' | ||
exclude = ''' | ||
/( | ||
\.git | ||
| \.hg | ||
| \.mypy_cache | ||
| \.tox | ||
| \.venv | ||
| _build | ||
| buck-out | ||
| build | ||
| dist | ||
# The following are specific to Black, you probably don't want those. | ||
| blib2to3 | ||
| tests/data | ||
)/ | ||
''' | ||
|
||
[tool.ruff] | ||
ignore = ["E501"] | ||
line-length = 89 | ||
select = [ | ||
"B", | ||
"B9", | ||
"C", | ||
"E", | ||
"F", | ||
"W", | ||
] | ||
target-version = "py39" | ||
|
||
[tool.ruff.mccabe] | ||
max-complexity = 18 | ||
|
||
[tool.ruff.per-file-ignores] | ||
"__init__.py" = [ | ||
"F401", | ||
"F403", | ||
] |
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.