feat(db): add datetime column dual-caret sort on inventory and weighing lists.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7579c36fc6
commit
100b0880f0
11 files changed
+42746
-40718
No files matched your search
@@ -15,6 +15,7 @@ from app.core.tenant_context import get_tenant_no
|
||||
from app.services.db_data_scope import apply_db_scope, assert_db_row_in_scope
|
||||
from app.services.db.inventory_id import next_inbound_outbound_id
|
||||
from app.services.db.inventory_list_filters import build_inventory_column_filters
|
||||
from app.services.db.list_sort import order_inventory, parse_sort_params
|
||||
from app.models.db_models import DbInboundOutbound, DbPurchasePlan, DbWeighingSlip
|
||||
from app.schemas.db.inventory import (
|
||||
CreateLinkForPlanPayload,
|
||||
@@ -226,10 +227,7 @@ def _fetch_inventory(
|
||||
db: Session, user: DbUserContext, params: dict
|
||||
) -> list[InboundOutboundRead]:
|
||||
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
|
||||
query = _base_query(db, tenant_no).order_by(
|
||||
DbInboundOutbound.date.desc(),
|
||||
DbInboundOutbound.id.desc(),
|
||||
)
|
||||
query = _base_query(db, tenant_no)
|
||||
|
||||
q = _param_get(params, "q")
|
||||
if q:
|
||||
@@ -249,6 +247,11 @@ def _fetch_inventory(
|
||||
query = query.filter(*column_filters)
|
||||
|
||||
query = apply_db_scope(query, DbInboundOutbound, user, db, tenant_no)
|
||||
sf, so = parse_sort_params(params)
|
||||
query = query.order_by(
|
||||
order_inventory(sf, so, default=DbInboundOutbound.date.desc()),
|
||||
DbInboundOutbound.id.desc(),
|
||||
)
|
||||
inventories = query.all()
|
||||
inventory_ids = [inv.id for inv in inventories]
|
||||
weighing_map: dict[str, DbWeighingSlip] = {}
|
||||
@@ -355,6 +358,8 @@ class InventoryExportBody(BaseModel):
|
||||
date_to: Optional[str] = Field(default=None, alias="dateTo")
|
||||
status: Optional[str] = None
|
||||
business_type: Optional[str] = Field(default=None, alias="businessType")
|
||||
sort_field: Optional[str] = Field(default=None, alias="sortField")
|
||||
sort_order: Optional[str] = Field(default=None, alias="sortOrder")
|
||||
ids: Optional[List[str]] = None
|
||||
columns: Optional[List[str]] = None
|
||||
|
||||
|
||||
Reference in new issue
Block a user