|
1 | 1 | import uuid |
2 | | -from datetime import datetime |
| 2 | +from datetime import datetime, timezone |
3 | 3 | from typing import Any, Optional, override |
4 | 4 |
|
5 | 5 | import sqlalchemy as sa |
@@ -122,7 +122,7 @@ class ArtifactOrderingApplier(BaseOrderingApplier[ArtifactOrderingOptions]): |
122 | 122 | @override |
123 | 123 | def get_order_column(self, field) -> sa.Column: |
124 | 124 | """Get the SQLAlchemy column for the given artifact field""" |
125 | | - return getattr(ArtifactRow, field.value, ArtifactRow.name) |
| 125 | + return getattr(ArtifactRow, field.value.lower(), ArtifactRow.name) |
126 | 126 |
|
127 | 127 |
|
128 | 128 | class ArtifactModelConverter: |
@@ -323,7 +323,7 @@ async def upsert_artifacts( |
323 | 323 | has_changes = existing_artifact.description != artifact_data.description |
324 | 324 | if has_changes: |
325 | 325 | existing_artifact.description = artifact_data.description |
326 | | - existing_artifact.updated_at = datetime.now() |
| 326 | + existing_artifact.updated_at = datetime.now(timezone.utc) |
327 | 327 |
|
328 | 328 | await db_sess.flush() |
329 | 329 | await db_sess.refresh( |
@@ -745,7 +745,10 @@ async def list_artifacts_paginated( |
745 | 745 | result = await db_sess.execute(querybuild_result.data_query) |
746 | 746 | rows = result.scalars().all() |
747 | 747 |
|
| 748 | + # Build count query with same filters applied |
748 | 749 | count_stmt = sa.select(sa.func.count()).select_from(ArtifactRow) |
| 750 | + if filters is not None: |
| 751 | + count_stmt = artifact_paginator.filter_applier.apply_filters(count_stmt, filters) |
749 | 752 | count_result = await db_sess.execute(count_stmt) |
750 | 753 | total_count = count_result.scalar() |
751 | 754 |
|
@@ -803,7 +806,10 @@ async def list_artifacts_with_revisions_paginated( |
803 | 806 | result = await db_sess.execute(querybuild_result.data_query) |
804 | 807 | rows = result.scalars().all() |
805 | 808 |
|
| 809 | + # Build count query with same filters applied |
806 | 810 | count_stmt = sa.select(sa.func.count()).select_from(ArtifactRow) |
| 811 | + if filters is not None: |
| 812 | + count_stmt = artifact_paginator.filter_applier.apply_filters(count_stmt, filters) |
807 | 813 | count_result = await db_sess.execute(count_stmt) |
808 | 814 | total_count = count_result.scalar() |
809 | 815 |
|
|
0 commit comments