Skip to content

Commit

Permalink
feat(api): add score_qualite field
Browse files Browse the repository at this point in the history
  • Loading branch information
vmttn committed Sep 27, 2024
1 parent fa2008a commit 3d61d10
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""add-score-qualite
Revision ID: 68fe052dc63c
Revises: e3f3dfa4ad01
Create Date: 2024-08-13 15:13:29.690054
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "68fe052dc63c"
down_revision = "e3f3dfa4ad01"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.add_column(
"api__services", sa.Column("score_qualite", sa.Float(), nullable=True)
)
op.execute("UPDATE api__services SET score_qualite = 0.5")
op.alter_column("api__services", "score_qualite", nullable=False)


def downgrade() -> None:
op.drop_column("api__services", "score_qualite")
1 change: 1 addition & 0 deletions api/src/data_inclusion/api/inclusion_data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Service(Base):
zone_diffusion_code: Mapped[str | None]
zone_diffusion_nom: Mapped[str | None]
zone_diffusion_type: Mapped[str | None]
score_qualite: Mapped[float]

commune_: Mapped[Commune] = relationship(back_populates="services")

Expand Down
16 changes: 15 additions & 1 deletion api/src/data_inclusion/api/inclusion_data/schemas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from pydantic import BaseModel, ConfigDict
from textwrap import dedent
from typing import Annotated

from pydantic import BaseModel, ConfigDict, Field

from data_inclusion import schema

Expand All @@ -17,6 +20,17 @@ class Service(schema.Service):
formulaire_en_ligne: str | None = None
lien_source: str | None = None

score_qualite: Annotated[
float,
Field(
ge=0,
le=1,
description=dedent("""\
Score de qualité du service, défini et calculé par data·inclusion.
"""),
),
]


class Structure(schema.Structure):
model_config = ConfigDict(from_attributes=True, populate_by_name=True)
Expand Down
18 changes: 17 additions & 1 deletion api/tests/e2e/api/__snapshots__/test_inclusion_data.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,13 @@
],
"title": "Modes Orientation Accompagnateur Autres"
},
"score_qualite": {
"type": "number",
"maximum": 1.0,
"minimum": 0.0,
"title": "Score Qualite",
"description": "Score de qualité du service, défini et calculé par data·inclusion.\n"
},
"structure": {
"$ref": "#/components/schemas/Structure"
}
Expand All @@ -1886,6 +1893,7 @@
"structure_id",
"source",
"nom",
"score_qualite",
"structure"
],
"title": "DetailedService"
Expand Down Expand Up @@ -2961,14 +2969,22 @@
}
],
"title": "Modes Orientation Accompagnateur Autres"
},
"score_qualite": {
"type": "number",
"maximum": 1.0,
"minimum": 0.0,
"title": "Score Qualite",
"description": "Score de qualité du service, défini et calculé par data·inclusion.\n"
}
},
"type": "object",
"required": [
"id",
"structure_id",
"source",
"nom"
"nom",
"score_qualite"
],
"title": "Service"
},
Expand Down
1 change: 1 addition & 0 deletions api/tests/e2e/api/test_inclusion_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def test_list_services_all(api_client):
"prise_rdv": "https://teixeira.fr/",
"profils": ["femmes"],
"recurrence": None,
"score_qualite": 0.5,
"source": "dora",
"structure_id": "prince-point-monde",
"telephone": "0102030405",
Expand Down
2 changes: 2 additions & 0 deletions api/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,5 @@ class Meta:
zone_diffusion_type = None
zone_diffusion_code = None
zone_diffusion_nom = None

score_qualite = 0.5

0 comments on commit 3d61d10

Please sign in to comment.