-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENHANCEMENT]
argilla server
: Return users on dataset progress (#5701)
# 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. --> This PR adds support to return a list of usernames in the dataset progress endpoint. **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Refactor (change restructuring the codebase without changing functionality) - Improvement (change adding some improvement to an existing functionality) **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
1 parent
b849166
commit 1338444
Showing
15 changed files
with
306 additions
and
61 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
argilla-server/src/argilla_server/alembic/versions/580a6553186f_add_datasets_users_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2021-present, the Recognai S.L. team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""add datasets_users table | ||
Revision ID: 580a6553186f | ||
Revises: 6ed1b8bf8e08 | ||
Create Date: 2024-11-20 12:15:24.631417 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "580a6553186f" | ||
down_revision = "6ed1b8bf8e08" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.create_table( | ||
"datasets_users", | ||
sa.Column("dataset_id", sa.Uuid(), nullable=False), | ||
sa.Column("user_id", sa.Uuid(), nullable=False), | ||
sa.Column("inserted_at", sa.DateTime(), nullable=False), | ||
sa.Column("updated_at", sa.DateTime(), nullable=False), | ||
sa.ForeignKeyConstraint(["dataset_id"], ["datasets.id"], ondelete="CASCADE"), | ||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"), | ||
sa.PrimaryKeyConstraint("dataset_id", "user_id"), | ||
) | ||
op.create_index(op.f("ix_datasets_users_dataset_id"), "datasets_users", ["dataset_id"], unique=False) | ||
op.create_index(op.f("ix_datasets_users_user_id"), "datasets_users", ["user_id"], unique=False) | ||
|
||
bind = op.get_bind() | ||
|
||
statement = """ | ||
INSERT INTO datasets_users (dataset_id, user_id, inserted_at, updated_at) | ||
SELECT dataset_id, user_id, {now_func}, {now_func} FROM ( | ||
SELECT DISTINCT records.dataset_id AS dataset_id, responses.user_id as user_id | ||
FROM responses | ||
JOIN records ON records.id = responses.record_id | ||
) AS subquery | ||
""" | ||
|
||
if bind.dialect.name == "postgresql": | ||
op.execute(statement.format(now_func="NOW()")) | ||
elif bind.dialect.name == "sqlite": | ||
op.execute(statement.format(now_func="datetime('now')")) | ||
else: | ||
raise Exception("Unsupported database dialect") | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_index(op.f("ix_datasets_users_user_id"), table_name="datasets_users") | ||
op.drop_index(op.f("ix_datasets_users_dataset_id"), table_name="datasets_users") | ||
op.drop_table("datasets_users") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
"2.0": "237f7c674d74", | ||
"2.4": "660d6c6b3360", | ||
"2.5": "6ed1b8bf8e08", | ||
"2.6": "580a6553186f", | ||
} | ||
) | ||
|
||
|
Oops, something went wrong.