Skip to content

Commit b936411

Browse files
pcrespovmrnicegyu11
authored andcommitted
šŸ› Fixes duplicates in tags listings and new priority to enforce order (ITISFoundation#6479)
1 parent b7065d9 commit b936411

File tree

16 files changed

+618
-223
lines changed

16 files changed

+618
-223
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""new tags priority column
2+
3+
Revision ID: 8a742f3efdd9
4+
Revises: 10729e07000d
5+
Create Date: 2024-10-02 15:23:27.446241+00:00
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "8a742f3efdd9"
13+
down_revision = "10729e07000d"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.add_column("tags", sa.Column("priority", sa.Integer(), nullable=True))
21+
# ### end Alembic commands ###
22+
23+
24+
def downgrade():
25+
# ### commands auto generated by Alembic - please adjust! ###
26+
op.drop_column("tags", "priority")
27+
# ### end Alembic commands ###

ā€Žpackages/postgres-database/src/simcore_postgres_database/models/services_tags.pyā€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@
1414
"service_key",
1515
sa.String,
1616
nullable=False,
17-
doc="Service Key Identifier",
17+
doc="Key name identifier for the service, without specifiying its versions",
1818
),
1919
sa.Column(
2020
"service_version",
2121
sa.String,
2222
nullable=False,
23-
doc="Service version",
23+
doc="Version of the service. Combined with 'service_key', it forms a unique identifier for this service.",
2424
),
2525
# Tag
2626
sa.Column(
2727
"tag_id",
2828
sa.BigInteger,
2929
sa.ForeignKey(tags.c.id, onupdate="CASCADE", ondelete="CASCADE"),
3030
nullable=False,
31+
doc="Identifier of the tag assigned to this specific service (service_key, service_version).",
3132
),
3233
# Constraints
3334
sa.ForeignKeyConstraint(

ā€Žpackages/postgres-database/src/simcore_postgres_database/models/tags.pyā€Ž

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,42 @@
22

33
from .base import metadata
44

5-
#
6-
# tags: a way to mark any entity (e.g. a project, ...)
7-
# this can be used to perform operations as filter, select, compare, etc
8-
#
95
tags = sa.Table(
6+
#
7+
# A way to mark any entity (e.g. a project, ...)
8+
# this can be used to perform operations as filter, select, compare, etc
9+
#
1010
"tags",
1111
metadata,
1212
sa.Column(
1313
"id",
1414
sa.BigInteger(),
1515
nullable=False,
1616
primary_key=True,
17+
doc="Unique identifier for each tag.",
1718
),
18-
sa.Column(
19-
"name",
20-
sa.String(),
21-
nullable=False,
22-
doc="display name",
23-
),
19+
sa.Column("name", sa.String(), nullable=False, doc="The display name of the tag."),
2420
sa.Column(
2521
"description",
2622
sa.String(),
2723
nullable=True,
28-
doc="description displayed",
24+
doc="A brief description displayed for the tag.",
2925
),
3026
sa.Column(
3127
"color",
3228
sa.String(),
3329
nullable=False,
34-
doc="Hex color (see https://www.color-hex.com/)",
30+
doc="Hexadecimal color code representing the tag (e.g., #FF5733).",
31+
),
32+
sa.Column(
33+
"priority",
34+
sa.Integer(),
35+
nullable=True,
36+
doc=(
37+
"Explicit ordering priority when displaying tags. "
38+
"Tags with a lower value are displayed first. "
39+
"If NULL, tags are considered to have the lowest priority and "
40+
"are displayed after non-NULL values, ordered by their ID (reflecting creation order)."
41+
),
3542
),
3643
)

ā€Žpackages/postgres-database/src/simcore_postgres_database/models/tags_access_rights.pyā€Ž

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
name="fk_tag_to_group_tag_id",
2323
),
2424
nullable=False,
25-
doc="Tag unique ID",
25+
doc="References the unique identifier of the tag that these access rights apply to.",
2626
),
2727
sa.Column(
2828
"group_id",
@@ -34,30 +34,32 @@
3434
name="fk_tag_to_group_group_id",
3535
),
3636
nullable=False,
37-
doc="Group unique ID",
37+
doc="References the unique identifier of the group that has access rights to the tag.",
3838
),
3939
# ACCESS RIGHTS ---
4040
sa.Column(
4141
"read",
4242
sa.Boolean(),
4343
nullable=False,
4444
server_default=sa.sql.expression.true(),
45-
doc="If true, group can *read* a tag."
46-
"This column can be used to set the tag invisible",
45+
doc="Indicates whether the group has permission to view the tag. "
46+
"A value of 'True' allows the group to access the tag's details.",
4747
),
4848
sa.Column(
4949
"write",
5050
sa.Boolean(),
5151
nullable=False,
5252
server_default=sa.sql.expression.false(),
53-
doc="If true, group can *create* and *update* a tag",
53+
doc="Indicates whether the group has permission to modify the tag. "
54+
"A value of 'True' grants write access to the group.",
5455
),
5556
sa.Column(
5657
"delete",
5758
sa.Boolean(),
5859
nullable=False,
5960
server_default=sa.sql.expression.false(),
60-
doc="If true, group can *delete* the tag",
61+
doc="Indicates whether the group has permission to delete the tag. "
62+
"A value of 'True' allows the group to remove the tag.",
6163
),
6264
# TIME STAMPS ----
6365
column_created_datetime(timezone=False),

0 commit comments

Comments
Ā (0)