Skip to content

Commit

Permalink
Update strategy to a simpler one
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaupetit committed Jan 8, 2025
1 parent 73c533d commit 9b231f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/api/qualicharge/models/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,16 @@ def not_future(value: date):
# A date not in the future (today or in the past)
NotFutureDate = Annotated[date, AfterValidator(not_future)]

# Default values (if not provided)
DEFAULT_CHAR_VALUE: str = "NA"
DEFAULT_EMAIL_ADDRESS: str = "[email protected]"
DEFAULT_PHONE_NUMBER: FrenchPhoneNumber = FrenchPhoneNumber("+33.123456789")


class Statique(ModelSchemaMixin, BaseModel):
"""IRVE static model."""

nom_amenageur: Optional[str]
nom_amenageur: Optional[str] = DEFAULT_CHAR_VALUE
siren_amenageur: Optional[
Annotated[
str,
Expand All @@ -135,11 +140,11 @@ class Statique(ModelSchemaMixin, BaseModel):
],
),
]
]
contact_amenageur: Optional[EmailStr]
nom_operateur: Optional[str]
] = "123456789"
contact_amenageur: Optional[EmailStr] = DEFAULT_EMAIL_ADDRESS
nom_operateur: Optional[str] = DEFAULT_CHAR_VALUE
contact_operateur: EmailStr
telephone_operateur: Optional[FrenchPhoneNumber]
telephone_operateur: Optional[FrenchPhoneNumber] = DEFAULT_PHONE_NUMBER
nom_enseigne: str
id_station_itinerance: Annotated[
str, Field(pattern="(?:(?:^|,)(^[A-Z]{2}[A-Z0-9]{4,33}$|Non concerné))+$")
Expand Down
2 changes: 0 additions & 2 deletions src/api/qualicharge/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from sqlalchemy.types import DateTime
from sqlmodel import Field, SQLModel

DEFAULT_CHAR_VALUE: str = "NA"


class BaseTimestampedSQLModel(SQLModel):
"""A base class for SQL models with timestamp fields.
Expand Down
7 changes: 4 additions & 3 deletions src/api/qualicharge/schemas/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from typing_extensions import Optional

from ..exceptions import ObjectDoesNotExist, ProgrammingError
from ..models.static import Statique
from . import DEFAULT_CHAR_VALUE, BaseTimestampedSQLModel
from ..models.static import DEFAULT_CHAR_VALUE, Statique
from . import BaseTimestampedSQLModel
from .core import (
AccessibilitePMREnum,
Amenageur,
Expand All @@ -43,7 +43,8 @@ def __init__(self, df: pd.DataFrame, connection: Connection):
"""Add table cache keys."""
logger.info("Loading input dataframe containing %d rows", len(df))

self._statique: pd.DataFrame = self._fill_na(self._fix_enums(df))
# self._statique: pd.DataFrame = self._fill_na(self._fix_enums(df))
self._statique: pd.DataFrame = self._fix_enums(df)
self._statique_with_fk: pd.DataFrame = self._statique.copy()
self._saved_schemas: list[type[BaseTimestampedSQLModel]] = []

Expand Down

0 comments on commit 9b231f8

Please sign in to comment.