feat: Add dialog for creating and editing historical tariff fractions and implement deterministic sorting for fraction listings.
This commit is contained in:
@@ -36,6 +36,8 @@ class CanadianTariffFractionService:
|
||||
)
|
||||
|
||||
total = self.db.execute(select(func.count()).select_from(query.subquery())).scalar_one()
|
||||
# Add deterministic sort order
|
||||
query = query.order_by(CanadianTariffFraction.fraction)
|
||||
items = self.db.scalars(query.offset(skip).limit(limit)).all()
|
||||
return items, total
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ class HistoricalTariffFractionService:
|
||||
query = query.where(HistoricalTariffFraction.historical_fraction.ilike(f"%{historical_fraction}%"))
|
||||
|
||||
total = self.db.execute(select(func.count()).select_from(query.subquery())).scalar_one()
|
||||
# Add deterministic sort order
|
||||
query = query.order_by(HistoricalTariffFraction.historical_fraction)
|
||||
items = self.db.scalars(query.offset(skip).limit(limit)).all()
|
||||
return items, total
|
||||
|
||||
|
||||
@@ -291,6 +291,8 @@ class TariffFractionService:
|
||||
query = query.filter(TariffFraction.umt.ilike(f"%{filters['umt']}%"))
|
||||
|
||||
total = query.count()
|
||||
# Add deterministic sort order
|
||||
query = query.order_by(TariffFraction.fraction)
|
||||
items = query.offset(skip).limit(limit).all()
|
||||
|
||||
return items, total
|
||||
|
||||
@@ -32,6 +32,8 @@ def list_sectors(
|
||||
query = query.filter(search_filter)
|
||||
|
||||
total = query.count()
|
||||
# Add deterministic sort order
|
||||
query = query.order_by(Sector.key)
|
||||
items = query.offset(skip).limit(page_size).all()
|
||||
|
||||
return {
|
||||
|
||||
@@ -86,6 +86,8 @@ class SitarAPIBaseService:
|
||||
httpx.HTTPError: If request fails
|
||||
"""
|
||||
token = await self._get_token()
|
||||
# Ensure no double slash between fractures and endpoint
|
||||
endpoint = endpoint.lstrip("/")
|
||||
url = f"{self.base_url}/fractions/{endpoint}"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {token}",
|
||||
|
||||
Reference in New Issue
Block a user