bookmyservice-mhs / app /utils /constants.py
MukeshKapoor25's picture
feat(services): replace RuntimeError with HTTPException in helper functions
d8d19cc
"""
Constants for the merchant hub service.
This file contains all magic numbers and hardcoded values used throughout the application.
"""
# Time-related constants
DEFAULT_RECENT_DAYS = 15
EARLY_OPENING_TIME = "09:00"
LATE_CLOSING_TIME = "20:00"
# Pagination and limits
DEFAULT_LIMIT = 10
DEFAULT_OFFSET = 0
# Geospatial constants
DEFAULT_SEARCH_RADIUS_METERS = 50000 # 50km default search radius
EARTH_RADIUS_KM = 6378.1
EARTH_RADIUS_METERS = 6378100.0
# Rating constants
MIN_RATING = 1
MAX_RATING = 5
# Business hours constants
BUSINESS_HOURS_FORMAT = "%H:%M"
# Search and sorting constants
DEFAULT_SORT_ORDER = "desc"
VALID_SORT_FIELDS = ["recommended", "price", "rating", "distance", "popularity", "trending", "recent"]
VALID_SORT_ORDERS = ["asc", "desc"]
# Availability options
AVAILABILITY_NOW = "now"
AVAILABILITY_ALL = "all"
AVAILABILITY_EARLY = "early"
AVAILABILITY_LATE = "late"
VALID_AVAILABILITY_OPTIONS = [AVAILABILITY_NOW, AVAILABILITY_ALL, AVAILABILITY_EARLY, AVAILABILITY_LATE]
# Error messages
ERROR_MERCHANT_NOT_FOUND = "Merchant not found"
ERROR_BUSINESS_HOURS_NOT_FOUND = "Business hours not found"
ERROR_BUSINESS_HOURS_UNAVAILABLE = "Business hours data is unavailable"
ERROR_FAILED_FETCH_MERCHANTS = "Failed to fetch recommended merchants"
ERROR_FAILED_FETCH_ADS = "Failed to fetch ad campaigns"
ERROR_FAILED_FETCH_SEARCH = "Failed to fetch search list"
ERROR_FAILED_FETCH_DETAILS = "Failed to fetch merchant details"
ERROR_FAILED_FETCH_REVIEWS = "Failed to fetch merchant reviews"
ERROR_FAILED_FETCH_BUSINESS_HOURS = "Failed to fetch business hours"
ERROR_NO_DEFAULT_CATEGORY = "No default category found"
ERROR_FAILED_FETCH_CATEGORIES = "Failed to fetch business categories"
ERROR_FAILED_FETCH_LOCATIONS = "Failed to fetch live locations"
# HTTP Status codes
HTTP_STATUS_OK = 200
HTTP_STATUS_NOT_FOUND = 404
HTTP_STATUS_INTERNAL_ERROR = 500