Skip to content

Commit

Permalink
[BUGFIX] argilla server: Prevent update dataset.updated_at when upd…
Browse files Browse the repository at this point in the history
…ating `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]>
  • Loading branch information
frascuchon and jfcalvo committed Nov 8, 2024
1 parent 86fb672 commit 6336c57
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions argilla-server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ These are the section headers that we use:

## [Unreleased]()

### Fixed

- 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))

## [2.4.0](https://github.com/argilla-io/argilla/compare/v2.3.1...v2.4.0)

### Added
Expand Down
7 changes: 6 additions & 1 deletion argilla-server/src/argilla_server/contexts/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@

async def _touch_dataset_last_activity_at(db: AsyncSession, dataset: Dataset) -> None:
await db.execute(
sqlalchemy.update(Dataset).where(Dataset.id == dataset.id).values(last_activity_at=datetime.utcnow())
sqlalchemy.update(Dataset)
.where(Dataset.id == dataset.id)
.values(
last_activity_at=datetime.utcnow(),
updated_at=Dataset.__table__.c.updated_at,
)
)


Expand Down
2 changes: 2 additions & 0 deletions argilla-server/tests/unit/api/handlers/v1/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async def test_update_response(
"updated_at": datetime.fromisoformat(resp_body["updated_at"]).isoformat(),
}

await db.refresh(dataset)
assert dataset.last_activity_at > dataset_previous_last_activity_at
assert dataset.updated_at == dataset_previous_updated_at

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

await db.refresh(dataset)
assert dataset.last_activity_at > dataset_previous_last_activity_at
assert dataset.updated_at == dataset_previous_updated_at

Expand Down

0 comments on commit 6336c57

Please sign in to comment.