feat: unify scope settings and catalog table interactions
Deploy production / deploy (push) Successful in 54s
Deploy production / deploy (push) Successful in 54s
This commit is contained in:
@@ -138,9 +138,12 @@ class Preparations:
|
||||
async def online_fields(self, filters):
|
||||
text_filters = (filters.q, filters.dataset_id, filters.field_type)
|
||||
numeric_filters = (
|
||||
filters.coverage_min, filters.coverage_max,
|
||||
filters.user_count_min, filters.user_count_max,
|
||||
filters.alpha_count_min, filters.alpha_count_max,
|
||||
filters.coverage_min,
|
||||
filters.coverage_max,
|
||||
filters.user_count_min,
|
||||
filters.user_count_max,
|
||||
filters.alpha_count_min,
|
||||
filters.alpha_count_max,
|
||||
)
|
||||
if not any(value and value.strip() for value in text_filters) and not any(
|
||||
value is not None for value in numeric_filters
|
||||
@@ -304,7 +307,7 @@ class Preparations:
|
||||
)
|
||||
)
|
||||
|
||||
async def list(self, q="", scope_key=None, limit=25, offset=0):
|
||||
async def list(self, q="", scope_key=None, limit=25, offset=0, sort="updated_at", direction="desc"):
|
||||
query = select(DataPreparation)
|
||||
if scope_key:
|
||||
query = query.where(DataPreparation.scope_key == scope_key)
|
||||
@@ -316,9 +319,13 @@ class Preparations:
|
||||
)
|
||||
)
|
||||
total = await self.db.scalar(select(func.count()).select_from(query.subquery()))
|
||||
rows = await self.db.scalars(
|
||||
query.order_by(DataPreparation.updated_at.desc(), DataPreparation.id).limit(limit).offset(offset)
|
||||
)
|
||||
column = {
|
||||
"name": DataPreparation.name,
|
||||
"created_at": DataPreparation.created_at,
|
||||
"updated_at": DataPreparation.updated_at,
|
||||
}[sort]
|
||||
order = column.asc() if direction == "asc" else column.desc()
|
||||
rows = await self.db.scalars(query.order_by(order, DataPreparation.id).limit(limit).offset(offset))
|
||||
return page([await self.output(row) for row in rows], total, limit, offset)
|
||||
|
||||
async def members(self, preparation_id, q="", dataset_id=None, limit=25, offset=0):
|
||||
|
||||
Reference in New Issue
Block a user