Skip to content

Commit

Permalink
feat(api): remove requests
Browse files Browse the repository at this point in the history
  • Loading branch information
hlecuyer committed Dec 17, 2024
1 parent 143be7a commit fe28f8c
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 167 deletions.
1 change: 0 additions & 1 deletion api/src/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from data_inclusion.api.core import db
from data_inclusion.api.decoupage_administratif import models as _ # noqa: F401 F811
from data_inclusion.api.inclusion_data import models as _ # noqa: F401 F811
from data_inclusion.api.request import models as _ # noqa: F401 F811

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""remove request
Revision ID: bc02c1c6f60e
Revises: 89e1ece4f56e
Create Date: 2024-12-17 10:34:25.120009
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "bc02c1c6f60e"
down_revision = "89e1ece4f56e"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.drop_table("api__requests")
pass


def downgrade() -> None:
op.create_table(
"api__requests",
sa.Column("id", sa.Uuid(), nullable=False),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.Column("status_code", sa.Integer(), nullable=False),
sa.Column("method", sa.String(), nullable=False),
sa.Column("path", sa.String(), nullable=False),
sa.Column("base_url", sa.String(), nullable=False),
sa.Column("user", sa.String(), nullable=True),
sa.Column(
"path_params", postgresql.JSONB(astext_type=sa.Text()), nullable=True
),
sa.Column(
"query_params", postgresql.JSONB(astext_type=sa.Text()), nullable=True
),
sa.Column("client_host", sa.String(), nullable=True),
sa.Column("client_port", sa.Integer(), nullable=True),
sa.Column("endpoint_name", sa.String(), nullable=True),
sa.PrimaryKeyConstraint("id", name=op.f("pk_api__requests")),
)
with op.get_context().autocommit_block():
op.create_index(
op.f("ix_api__requests__created_at"),
"api__requests",
["created_at"],
unique=False,
postgresql_concurrently=True,
)
op.create_index(
op.f("ix_api__requests__endpoint_name"),
"api__requests",
["endpoint_name"],
unique=False,
postgresql_concurrently=True,
)
op.create_index(
op.f("ix_api__requests__method"),
"api__requests",
["method"],
unique=False,
postgresql_concurrently=True,
)
op.create_index(
op.f("ix_api__requests__status_code"),
"api__requests",
["status_code"],
unique=False,
postgresql_concurrently=True,
)
op.create_index(
op.f("ix_api__requests__user"),
"api__requests",
["user"],
unique=False,
postgresql_concurrently=True,
)
2 changes: 0 additions & 2 deletions api/src/data_inclusion/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from data_inclusion.api.core import db
from data_inclusion.api.inclusion_data.routes import router as data_api_router
from data_inclusion.api.inclusion_schema.routes import router as schema_api_router
from data_inclusion.api.request.middleware import save_request_middleware

API_DESCRIPTION_PATH = Path(__file__).parent / "api_description.md"

Expand Down Expand Up @@ -74,7 +73,6 @@ def create_app() -> fastapi.FastAPI:
setup_debug_toolbar_middleware(app)

app.middleware("http")(db.db_session_middleware)
app.middleware("http")(save_request_middleware)

app.include_router(v0_api_router)
app.include_router(
Expand Down
Empty file.
22 changes: 0 additions & 22 deletions api/src/data_inclusion/api/request/middleware.py

This file was deleted.

27 changes: 0 additions & 27 deletions api/src/data_inclusion/api/request/models.py

This file was deleted.

47 changes: 0 additions & 47 deletions api/src/data_inclusion/api/request/services.py

This file was deleted.

2 changes: 0 additions & 2 deletions api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def db_session(db_connection):

factories.StructureFactory._meta.sqlalchemy_session = session
factories.ServiceFactory._meta.sqlalchemy_session = session
factories.RequestFactory._meta.sqlalchemy_session = session

yield session

Expand All @@ -157,6 +156,5 @@ def predictable_sequences():
import factory.random

factory.random.reseed_random(0)
factories.RequestFactory.reset_sequence()
factories.ServiceFactory.reset_sequence()
factories.StructureFactory.reset_sequence()
57 changes: 0 additions & 57 deletions api/tests/e2e/api/test_request.py

This file was deleted.

9 changes: 0 additions & 9 deletions api/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,10 @@

from data_inclusion import schema as di_schema
from data_inclusion.api.inclusion_data import models
from data_inclusion.api.request.models import Request

fake = faker.Faker("fr_FR")


class RequestFactory(factory.alchemy.SQLAlchemyModelFactory):
class Meta:
model = Request
sqlalchemy_session_persistence = "commit"

status_code = 200


class StructureFactory(factory.alchemy.SQLAlchemyModelFactory):
class Meta:
model = models.Structure
Expand Down

0 comments on commit fe28f8c

Please sign in to comment.