Skip to content

Commit

Permalink
Rename LocationOSMType to LocationOSMEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Nov 25, 2023
1 parent 09b42de commit 7b1ef1b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sqlalchemy.sql import func

from app import config
from app.enums import LocationOSMType
from app.enums import LocationOSMEnum
from app.models import Location, Price, Product, Proof, User
from app.schemas import (
LocationBase,
Expand Down Expand Up @@ -214,7 +214,7 @@ def get_location_by_id(db: Session, id: int):


def get_location_by_osm_id_and_type(
db: Session, osm_id: int, osm_type: LocationOSMType
db: Session, osm_id: int, osm_type: LocationOSMEnum
):
return (
db.query(Location)
Expand Down
2 changes: 1 addition & 1 deletion app/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
CurrencyEnum = Enum("CurrencyEnum", CURRENCIES)


class LocationOSMType(Enum):
class LocationOSMEnum(Enum):
NODE = "NODE"
WAY = "WAY"
RELATION = "RELATION"
6 changes: 3 additions & 3 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from sqlalchemy_utils.types.choice import ChoiceType

from app.db import Base
from app.enums import CurrencyEnum, LocationOSMType
from app.enums import CurrencyEnum, LocationOSMEnum

force_auto_coercion()

Expand Down Expand Up @@ -54,7 +54,7 @@ class Location(Base):
id = Column(Integer, primary_key=True, index=True)

osm_id = Column(BigInteger)
osm_type = Column(ChoiceType(LocationOSMType))
osm_type = Column(ChoiceType(LocationOSMEnum))
osm_name = Column(String)
osm_display_name = Column(String)
osm_address_postcode = Column(String)
Expand Down Expand Up @@ -99,7 +99,7 @@ class Price(Base):
currency = Column(ChoiceType(CurrencyEnum))

location_osm_id = Column(BigInteger, index=True)
location_osm_type = Column(ChoiceType(LocationOSMType))
location_osm_type = Column(ChoiceType(LocationOSMEnum))
location_id: Mapped[int] = mapped_column(ForeignKey("locations.id"), nullable=True)
location: Mapped[Location] = relationship(back_populates="prices")

Expand Down
8 changes: 4 additions & 4 deletions app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
model_validator,
)

from app.enums import CurrencyEnum, LocationOSMType
from app.enums import CurrencyEnum, LocationOSMEnum
from app.models import Price


Expand Down Expand Up @@ -63,7 +63,7 @@ class LocationCreate(BaseModel):
model_config = ConfigDict(from_attributes=True, arbitrary_types_allowed=True)

osm_id: int = Field(gt=0)
osm_type: LocationOSMType
osm_type: LocationOSMEnum


class LocationBase(LocationCreate):
Expand Down Expand Up @@ -135,7 +135,7 @@ class PriceCreate(BaseModel):
description="ID of the location in OpenStreetMap: the store where the product was bought.",
examples=[1234567890],
)
location_osm_type: LocationOSMType = Field(
location_osm_type: LocationOSMEnum = Field(
description="type of the OpenStreetMap location object. Stores can be represented as nodes, "
"ways or relations in OpenStreetMap. It is necessary to be able to fetch the correct "
"information about the store using the ID.",
Expand Down Expand Up @@ -192,7 +192,7 @@ class ProofBase(ProofCreate):
class PriceFilter(Filter):
product_code: Optional[str] | None = None
location_osm_id: Optional[int] | None = None
location_osm_type: Optional[LocationOSMType] | None = None
location_osm_type: Optional[LocationOSMEnum] | None = None
price: Optional[int] | None = None
currency: Optional[str] | None = None
price__gt: Optional[int] | None = None
Expand Down

0 comments on commit 7b1ef1b

Please sign in to comment.