Skip to content

Commit a0e7634

Browse files
committed
sonar
1 parent 30e931f commit a0e7634

File tree

1 file changed

+84
-78
lines changed
  • services/web/server/src/simcore_service_webserver/user_notifications

1 file changed

+84
-78
lines changed

services/web/server/src/simcore_service_webserver/user_notifications/_models.py

Lines changed: 84 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from models_library.users import UserID
88
from models_library.utils.enums import StrAutoEnum
99
from pydantic import BaseModel, ConfigDict, NonNegativeInt, field_validator
10+
from pydantic.config import JsonDict
1011

1112
MAX_NOTIFICATIONS_FOR_USER_TO_SHOW: Final[NonNegativeInt] = 10
1213
MAX_NOTIFICATIONS_FOR_USER_TO_KEEP: Final[NonNegativeInt] = 100
@@ -64,81 +65,86 @@ def create_from_request_data(
6465
id=f"{uuid4()}", read=False, **request_data.model_dump()
6566
)
6667

67-
model_config = ConfigDict(
68-
json_schema_extra={
69-
"examples": [
70-
{
71-
"id": "3fb96d89-ff5d-4d27-b5aa-d20d46e20eb8",
72-
"user_id": "1",
73-
"category": "NEW_ORGANIZATION",
74-
"actionable_path": "organization/40",
75-
"title": "New organization",
76-
"text": "You're now member of a new Organization",
77-
"date": "2023-02-23T16:23:13.122Z",
78-
"product": "osparc",
79-
"read": True,
80-
},
81-
{
82-
"id": "ba64ffce-c58c-4382-aad6-96a7787251d6",
83-
"user_id": "1",
84-
"category": "STUDY_SHARED",
85-
"actionable_path": "study/27edd65c-b360-11ed-93d7-02420a000014",
86-
"title": "Study shared",
87-
"text": "A study was shared with you",
88-
"date": "2023-02-23T16:25:13.122Z",
89-
"product": "osparc",
90-
"read": False,
91-
},
92-
{
93-
"id": "390053c9-3931-40e1-839f-585268f6fd3c",
94-
"user_id": "1",
95-
"category": "TEMPLATE_SHARED",
96-
"actionable_path": "template/f60477b6-a07e-11ed-8d29-02420a00002d",
97-
"title": "Template shared",
98-
"text": "A template was shared with you",
99-
"date": "2023-02-23T16:28:13.122Z",
100-
"product": "osparc",
101-
"read": False,
102-
},
103-
{
104-
"id": "390053c9-3931-40e1-839f-585268f6fd3d",
105-
"user_id": "1",
106-
"category": "CONVERSATION_NOTIFICATION",
107-
"actionable_path": "study/27edd65c-b360-11ed-93d7-02420a000014",
108-
"title": "New notification",
109-
"text": "You were notified in a conversation",
110-
"date": "2023-02-23T16:28:13.122Z",
111-
"product": "s4l",
112-
"read": False,
113-
"resource_id": "3fb96d89-ff5d-4d27-b5aa-d20d46e20e12",
114-
"user_from_id": "2",
115-
},
116-
{
117-
"id": "390053c9-3931-40e1-839f-585268f6fd3d",
118-
"user_id": "1",
119-
"category": "ANNOTATION_NOTE",
120-
"actionable_path": "study/27edd65c-b360-11ed-93d7-02420a000014",
121-
"title": "Note added",
122-
"text": "A Note was added for you",
123-
"date": "2023-02-23T16:28:13.122Z",
124-
"product": "s4l",
125-
"read": False,
126-
"resource_id": "3fb96d89-ff5d-4d27-b5aa-d20d46e20e12",
127-
"user_from_id": "2",
128-
},
129-
{
130-
"id": "390053c9-3931-40e1-839f-585268f6fd3e",
131-
"user_id": "1",
132-
"category": "WALLET_SHARED",
133-
"actionable_path": "wallet/21",
134-
"title": "Credits shared",
135-
"text": "A Credit account was shared with you",
136-
"date": "2023-09-29T16:28:13.122Z",
137-
"product": "tis",
138-
"read": False,
139-
"resource_id": "3fb96d89-ff5d-4d27-b5aa-d20d46e20e13",
140-
"user_from_id": "2",
141-
},
142-
]
143-
}
144-
)
68+
@staticmethod
69+
def _update_json_schema_extra(schema: JsonDict) -> None:
70+
71+
schema.update(
72+
{
73+
"examples": [ # NOSONAR
74+
{
75+
"id": "3fb96d89-ff5d-4d27-b5aa-d20d46e20eb8",
76+
"user_id": "1",
77+
"category": "NEW_ORGANIZATION",
78+
"actionable_path": "organization/40",
79+
"title": "New organization",
80+
"text": "You're now member of a new Organization",
81+
"date": "2023-02-23T16:23:13.122Z",
82+
"product": "osparc",
83+
"read": True,
84+
},
85+
{
86+
"id": "ba64ffce-c58c-4382-aad6-96a7787251d6",
87+
"user_id": "1",
88+
"category": "STUDY_SHARED",
89+
"actionable_path": "study/27edd65c-b360-11ed-93d7-02420a000014", # NOSONAR
90+
"title": "Study shared",
91+
"text": "A study was shared with you",
92+
"date": "2023-02-23T16:25:13.122Z",
93+
"product": "osparc",
94+
"read": False,
95+
},
96+
{
97+
"id": "390053c9-3931-40e1-839f-585268f6fd3c",
98+
"user_id": "1",
99+
"category": "TEMPLATE_SHARED",
100+
"actionable_path": "template/f60477b6-a07e-11ed-8d29-02420a00002d",
101+
"title": "Template shared",
102+
"text": "A template was shared with you",
103+
"date": "2023-02-23T16:28:13.122Z",
104+
"product": "osparc",
105+
"read": False,
106+
},
107+
{
108+
"id": "390053c9-3931-40e1-839f-585268f6fd3d",
109+
"user_id": "1",
110+
"category": "CONVERSATION_NOTIFICATION",
111+
"actionable_path": "study/27edd65c-b360-11ed-93d7-02420a000014", # NOSONAR
112+
"title": "New notification",
113+
"text": "You were notified in a conversation",
114+
"date": "2023-02-23T16:28:13.122Z",
115+
"product": "s4l",
116+
"read": False,
117+
"resource_id": "3fb96d89-ff5d-4d27-b5aa-d20d46e20e12",
118+
"user_from_id": "2",
119+
},
120+
{
121+
"id": "390053c9-3931-40e1-839f-585268f6fd3d",
122+
"user_id": "1",
123+
"category": "ANNOTATION_NOTE",
124+
"actionable_path": "study/27edd65c-b360-11ed-93d7-02420a000014", # NOSONAR
125+
"title": "Note added",
126+
"text": "A Note was added for you",
127+
"date": "2023-02-23T16:28:13.122Z",
128+
"product": "s4l",
129+
"read": False,
130+
"resource_id": "3fb96d89-ff5d-4d27-b5aa-d20d46e20e12",
131+
"user_from_id": "2",
132+
},
133+
{
134+
"id": "390053c9-3931-40e1-839f-585268f6fd3e",
135+
"user_id": "1",
136+
"category": "WALLET_SHARED",
137+
"actionable_path": "wallet/21",
138+
"title": "Credits shared",
139+
"text": "A Credit account was shared with you",
140+
"date": "2023-09-29T16:28:13.122Z",
141+
"product": "tis",
142+
"read": False,
143+
"resource_id": "3fb96d89-ff5d-4d27-b5aa-d20d46e20e13",
144+
"user_from_id": "2",
145+
},
146+
]
147+
}
148+
)
149+
150+
model_config = ConfigDict(json_schema_extra=_update_json_schema_extra)

0 commit comments

Comments
 (0)