Skip to content

Commit 7aa3ac8

Browse files
🎨 [Support center] reopen closed Fogbugz cases (🗃️) (ITISFoundation#8482)
1 parent 3ca1fb6 commit 7aa3ac8

File tree

16 files changed

+522
-147
lines changed

16 files changed

+522
-147
lines changed

packages/models-library/src/models_library/api_schemas_webserver/conversations.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ class ConversationRestGet(OutputSchema):
2626
project_uuid: ProjectID | None
2727
user_group_id: GroupID
2828
type: ConversationType
29+
fogbugz_case_id: str | None
2930
created: datetime
3031
modified: datetime
3132
extra_context: dict[str, str]
33+
is_read_by_user: bool
34+
is_read_by_support: bool
35+
last_message_created_at: datetime
3236

3337
@classmethod
3438
def from_domain_model(cls, domain: ConversationGetDB) -> Self:
@@ -39,15 +43,21 @@ def from_domain_model(cls, domain: ConversationGetDB) -> Self:
3943
project_uuid=domain.project_uuid,
4044
user_group_id=domain.user_group_id,
4145
type=domain.type,
46+
fogbugz_case_id=domain.fogbugz_case_id,
4247
created=domain.created,
4348
modified=domain.modified,
4449
extra_context=domain.extra_context,
50+
is_read_by_user=domain.is_read_by_user,
51+
is_read_by_support=domain.is_read_by_support,
52+
last_message_created_at=domain.last_message_created_at,
4553
)
4654

4755

4856
class ConversationPatch(InputSchema):
4957
name: str | None = None
5058
extra_context: dict[str, Any] | None = None
59+
is_read_by_user: bool | None = None
60+
is_read_by_support: bool | None = None
5161

5262

5363
### CONVERSATION MESSAGES ---------------------------------------------------------------

packages/models-library/src/models_library/conversations.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class ConversationMessageType(StrAutoEnum):
3838
#
3939

4040

41+
IsSupportUser: TypeAlias = bool
42+
43+
4144
class ConversationGetDB(BaseModel):
4245
conversation_id: ConversationID
4346
product_name: ProductName
@@ -46,10 +49,14 @@ class ConversationGetDB(BaseModel):
4649
user_group_id: GroupID
4750
type: ConversationType
4851
extra_context: dict[str, Any]
52+
fogbugz_case_id: str | None
53+
is_read_by_user: bool
54+
is_read_by_support: bool
4955

5056
# states
5157
created: datetime
5258
modified: datetime
59+
last_message_created_at: datetime
5360

5461
model_config = ConfigDict(from_attributes=True)
5562

@@ -71,6 +78,10 @@ class ConversationMessageGetDB(BaseModel):
7178
class ConversationPatchDB(BaseModel):
7279
name: ConversationName | None = None
7380
extra_context: dict[str, Any] | None = None
81+
fogbugz_case_id: str | None = None
82+
is_read_by_user: bool | None = None
83+
is_read_by_support: bool | None = None
84+
last_message_created_at: datetime | None = None
7485

7586

7687
class ConversationMessagePatchDB(BaseModel):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""add last_message_created_at column
2+
3+
Revision ID: a6289977e057
4+
Revises: dfdd4f8d4870
5+
Create Date: 2025-10-13 08:39:24.912539+00:00
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "a6289977e057"
14+
down_revision = "dfdd4f8d4870"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.add_column(
22+
"conversations",
23+
sa.Column(
24+
"last_message_created_at",
25+
sa.DateTime(timezone=True),
26+
server_default=sa.text("now()"),
27+
nullable=False,
28+
),
29+
)
30+
# ### end Alembic commands ###
31+
32+
# Data migration: populate last_message_created_at with modified column values
33+
op.execute("UPDATE conversations SET last_message_created_at = modified")
34+
35+
36+
def downgrade():
37+
# ### commands auto generated by Alembic - please adjust! ###
38+
op.drop_column("conversations", "last_message_created_at")
39+
# ### end Alembic commands ###
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""add read by user/support columns
2+
3+
Revision ID: dfdd4f8d4870
4+
Revises: 9dddb16914a4
5+
Create Date: 2025-10-10 12:07:12.014847+00:00
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "dfdd4f8d4870"
14+
down_revision = "9dddb16914a4"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.add_column(
22+
"conversations", sa.Column("fogbugz_case_id", sa.String(), nullable=True)
23+
)
24+
op.add_column(
25+
"conversations",
26+
sa.Column(
27+
"is_read_by_user",
28+
sa.Boolean(),
29+
server_default=sa.text("true"),
30+
nullable=False,
31+
),
32+
)
33+
op.add_column(
34+
"conversations",
35+
sa.Column(
36+
"is_read_by_support",
37+
sa.Boolean(),
38+
server_default=sa.text("true"),
39+
nullable=False,
40+
),
41+
)
42+
# ### end Alembic commands ###
43+
44+
45+
def downgrade():
46+
# ### commands auto generated by Alembic - please adjust! ###
47+
op.drop_column("conversations", "is_read_by_support")
48+
op.drop_column("conversations", "is_read_by_user")
49+
op.drop_column("conversations", "fogbugz_case_id")
50+
# ### end Alembic commands ###

packages/postgres-database/src/simcore_postgres_database/models/conversations.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,33 @@ class ConversationType(enum.Enum):
7878
server_default=sa.text("'{}'::jsonb"),
7979
doc="Free JSON to store extra context",
8080
),
81+
sa.Column(
82+
"fogbugz_case_id",
83+
sa.String,
84+
nullable=True,
85+
doc="Fogbugz case ID associated with the conversation",
86+
),
87+
sa.Column(
88+
"is_read_by_user",
89+
sa.Boolean,
90+
nullable=False,
91+
server_default=sa.text("true"),
92+
doc="Indicates if the message has been read by the user (true) or not (false)",
93+
),
94+
sa.Column(
95+
"is_read_by_support",
96+
sa.Boolean,
97+
nullable=False,
98+
server_default=sa.text("true"),
99+
doc="Indicates if the message has been read by the support user (true) or not (false)",
100+
),
101+
sa.Column(
102+
"last_message_created_at",
103+
sa.DateTime(timezone=True),
104+
nullable=False,
105+
server_default=sa.sql.func.now(),
106+
doc="Timestamp of the last message created in this conversation",
107+
),
81108
column_created_datetime(timezone=True),
82109
column_modified_datetime(timezone=True),
83110
)

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10327,6 +10327,16 @@ components:
1032710327
type: object
1032810328
- type: 'null'
1032910329
title: Extracontext
10330+
isReadByUser:
10331+
anyOf:
10332+
- type: boolean
10333+
- type: 'null'
10334+
title: Isreadbyuser
10335+
isReadBySupport:
10336+
anyOf:
10337+
- type: boolean
10338+
- type: 'null'
10339+
title: Isreadbysupport
1033010340
type: object
1033110341
title: ConversationPatch
1033210342
ConversationRestGet:
@@ -10355,6 +10365,11 @@ components:
1035510365
minimum: 0
1035610366
type:
1035710367
$ref: '#/components/schemas/ConversationType'
10368+
fogbugzCaseId:
10369+
anyOf:
10370+
- type: string
10371+
- type: 'null'
10372+
title: Fogbugzcaseid
1035810373
created:
1035910374
type: string
1036010375
format: date-time
@@ -10368,6 +10383,16 @@ components:
1036810383
type: string
1036910384
type: object
1037010385
title: Extracontext
10386+
isReadByUser:
10387+
type: boolean
10388+
title: Isreadbyuser
10389+
isReadBySupport:
10390+
type: boolean
10391+
title: Isreadbysupport
10392+
lastMessageCreatedAt:
10393+
type: string
10394+
format: date-time
10395+
title: Lastmessagecreatedat
1037110396
type: object
1037210397
required:
1037310398
- conversationId
@@ -10376,9 +10401,13 @@ components:
1037610401
- projectUuid
1037710402
- userGroupId
1037810403
- type
10404+
- fogbugzCaseId
1037910405
- created
1038010406
- modified
1038110407
- extraContext
10408+
- isReadByUser
10409+
- isReadBySupport
10410+
- lastMessageCreatedAt
1038210411
title: ConversationRestGet
1038310412
ConversationType:
1038410413
type: string

services/web/server/src/simcore_service_webserver/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ def create_application(tracing_config: TracingConfig) -> web.Application:
175175
setup_projects(app)
176176

177177
# conversations
178-
setup_conversations(app)
179178
setup_fogbugz(app) # Needed for support conversations
179+
setup_conversations(app)
180180

181181
# licenses
182182
setup_licenses(app)

0 commit comments

Comments
 (0)