Verified Commit 394bfc58 authored by Власов Иван Юрьевич's avatar Власов Иван Юрьевич :rabbit2:
Browse files

Added /getIndicatorGroups endpoint

parent 09274e49
No related merge requests found
Showing with 14 additions and 2 deletions
+14 -2
......@@ -2,5 +2,5 @@ from .oauth import github_oauth_callback, github_oauth_redirect
from .service import ping
from .user import get_me, create_bot_token, get_bot_tokens, delete_bot_token
from .parser import load_report
from .indicators import get_indicators_from_group
from .indicators import get_indicators_from_group, get_indicator_groups
from .watcher import create_watcher
......@@ -3,6 +3,7 @@ from tortoise.exceptions import DoesNotExist
from models import IndicatorGroup, Indicator
from models.indicator import IndicatorPD, IndicatorGroupPD
from models.users import UserPD
from responses.errors import IndicatorGroupDoesNotExist
from responses.responses import OkResponse
......@@ -25,3 +26,13 @@ async def get_indicators_from_group(request: Request):
indicator.report = None
indicators_pd.append(IndicatorPD.from_orm(indicator))
return OkResponse({"indicators": indicators_pd, "group": group_pd})
async def get_indicator_groups(request: Request):
""" Get all groups that belongs to user """
groups = await IndicatorGroup.filter(owner=request.state.user).all()
groups_pd = []
for group in groups:
group.owner = request.state.user
groups_pd.append(IndicatorGroupPD.from_orm(group))
return OkResponse(groups_pd)
......@@ -17,7 +17,8 @@ api_routes = [
Route("/createBotToken", create_bot_token, methods=["GET"]),
Route("/getBotTokens", get_bot_tokens, methods=["GET"]),
Route("/deleteBotToken", delete_bot_token, methods=["GET"]),
Route("/createWatcher", create_watcher, methods=["POST"])
Route("/createWatcher", create_watcher, methods=["POST"]),
Route("/getIndicatorGroups", get_indicator_groups, methods=["GET"])
]
admin_routes = []
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment