Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 9420fe3

Browse files
committed
chore: tidy up dashboard api naming
1 parent 7acb78f commit 9420fe3

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

api/openapi.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
],
3434
"summary": "Get Messages",
3535
"description": "Get all the messages from the database and return them as a list of conversations.",
36-
"operationId": "get_messages_api_v1_dashboard_messages_get",
36+
"operationId": "v1_get_messages",
3737
"responses": {
3838
"200": {
3939
"description": "Successful Response",
@@ -44,7 +44,7 @@
4444
"$ref": "#/components/schemas/Conversation"
4545
},
4646
"type": "array",
47-
"title": "Response Get Messages Api V1 Dashboard Messages Get"
47+
"title": "Response V1 Get Messages"
4848
}
4949
}
5050
}
@@ -60,7 +60,7 @@
6060
],
6161
"summary": "Get Alerts",
6262
"description": "Get all the messages from the database and return them as a list of conversations.",
63-
"operationId": "get_alerts_api_v1_dashboard_alerts_get",
63+
"operationId": "v1_get_alerts",
6464
"responses": {
6565
"200": {
6666
"description": "Successful Response",
@@ -78,7 +78,7 @@
7878
]
7979
},
8080
"type": "array",
81-
"title": "Response Get Alerts Api V1 Dashboard Alerts Get"
81+
"title": "Response V1 Get Alerts"
8282
}
8383
}
8484
}
@@ -94,7 +94,7 @@
9494
],
9595
"summary": "Stream Sse",
9696
"description": "Send alerts event",
97-
"operationId": "stream_sse_api_v1_dashboard_alerts_notification_get",
97+
"operationId": "v1_stream_sse",
9898
"responses": {
9999
"200": {
100100
"description": "Successful Response",
@@ -114,7 +114,7 @@
114114
"Dashboard"
115115
],
116116
"summary": "Version Check",
117-
"operationId": "version_check_api_v1_dashboard_version_get",
117+
"operationId": "v1_version_check",
118118
"responses": {
119119
"200": {
120120
"description": "Successful Response",

src/codegate/api/dashboard/dashboard.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
from typing import AsyncGenerator, List, Optional
33

4+
from fastapi.routing import APIRoute
45
import requests
56
import structlog
67
from fastapi import APIRouter, Depends, FastAPI
@@ -16,9 +17,12 @@
1617

1718
logger = structlog.get_logger("codegate")
1819

19-
dashboard_router = APIRouter(tags=["Dashboard"])
20+
dashboard_router = APIRouter()
2021
db_reader = None
2122

23+
def uniq_name(route: APIRoute):
24+
return f"v1_{route.name}"
25+
2226
def get_db_reader():
2327
global db_reader
2428
if db_reader is None:
@@ -36,7 +40,7 @@ def fetch_latest_version() -> str:
3640
data = response.json()
3741
return data.get("tag_name", "unknown")
3842

39-
@dashboard_router.get("/dashboard/messages")
43+
@dashboard_router.get("/dashboard/messages", tags=["Dashboard"], generate_unique_id_function=uniq_name)
4044
def get_messages(db_reader: DbReader = Depends(get_db_reader)) -> List[Conversation]:
4145
"""
4246
Get all the messages from the database and return them as a list of conversations.
@@ -46,7 +50,7 @@ def get_messages(db_reader: DbReader = Depends(get_db_reader)) -> List[Conversat
4650
return asyncio.run(parse_messages_in_conversations(prompts_outputs))
4751

4852

49-
@dashboard_router.get("/dashboard/alerts")
53+
@dashboard_router.get("/dashboard/alerts", tags=["Dashboard"], generate_unique_id_function=uniq_name)
5054
def get_alerts(db_reader: DbReader = Depends(get_db_reader)) -> List[Optional[AlertConversation]]:
5155
"""
5256
Get all the messages from the database and return them as a list of conversations.
@@ -64,14 +68,14 @@ async def generate_sse_events() -> AsyncGenerator[str, None]:
6468
yield f"data: {message}\n\n"
6569

6670

67-
@dashboard_router.get("/dashboard/alerts_notification")
71+
@dashboard_router.get("/dashboard/alerts_notification", tags=["Dashboard"], generate_unique_id_function=uniq_name)
6872
async def stream_sse():
6973
"""
7074
Send alerts event
7175
"""
7276
return StreamingResponse(generate_sse_events(), media_type="text/event-stream")
7377

74-
@dashboard_router.get("/dashboard/version")
78+
@dashboard_router.get("/dashboard/version", tags=["Dashboard"], generate_unique_id_function=uniq_name)
7579
def version_check():
7680
try:
7781
latest_version = fetch_latest_version()

0 commit comments

Comments
 (0)