Skip to content

Commit 7a5bf8a

Browse files
frascuchonjfcalvo
andauthored
[BUGFIX] argilla server: Prevent update dataset.updated_at when updating dataset.last_activity_at column (#5656)
# Description <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Closes #<issue_number> **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Bug fix (non-breaking change which fixes an issue) **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --------- Co-authored-by: José Francisco Calvo <[email protected]>
1 parent 9807e3e commit 7a5bf8a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

argilla-server/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ These are the section headers that we use:
1616

1717
## [Unreleased]()
1818

19+
### Fixed
20+
21+
- Fixed error so now `_touch_dataset_last_activity_at` function is not updating dataset's `updated_at` column. ([#5656](https://github.com/argilla-io/argilla/pull/5656))
22+
1923
## [2.4.0](https://github.com/argilla-io/argilla/compare/v2.3.1...v2.4.0)
2024

2125
### Added

argilla-server/src/argilla_server/contexts/datasets.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@
100100

101101
async def _touch_dataset_last_activity_at(db: AsyncSession, dataset: Dataset) -> None:
102102
await db.execute(
103-
sqlalchemy.update(Dataset).where(Dataset.id == dataset.id).values(last_activity_at=datetime.utcnow())
103+
sqlalchemy.update(Dataset)
104+
.where(Dataset.id == dataset.id)
105+
.values(
106+
last_activity_at=datetime.utcnow(),
107+
updated_at=Dataset.__table__.c.updated_at,
108+
)
104109
)
105110

106111

argilla-server/tests/unit/api/handlers/v1/test_responses.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ async def test_update_response(
102102
"updated_at": datetime.fromisoformat(resp_body["updated_at"]).isoformat(),
103103
}
104104

105+
await db.refresh(dataset)
105106
assert dataset.last_activity_at > dataset_previous_last_activity_at
106107
assert dataset.updated_at == dataset_previous_updated_at
107108

@@ -421,6 +422,7 @@ async def test_delete_response(
421422
assert resp.status_code == 200
422423
assert (await db.execute(select(func.count(Response.id)))).scalar() == 0
423424

425+
await db.refresh(dataset)
424426
assert dataset.last_activity_at > dataset_previous_last_activity_at
425427
assert dataset.updated_at == dataset_previous_updated_at
426428

0 commit comments

Comments
 (0)