This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from hotosm/feature/tm-stats
Tasking Manager stats
- Loading branch information
Showing
6 changed files
with
191 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (C) 2021 Humanitarian OpenStreetmap Team | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
|
||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
# Humanitarian OpenStreetmap Team | ||
# 1100 13th Street NW Suite 800 Washington, D.C. 20005 | ||
# <info@hotosm.org> | ||
|
||
"""[Router Responsible for Organizational data API ] | ||
""" | ||
from fastapi import APIRouter, Depends | ||
|
||
from .auth import login_required | ||
|
||
from src.galaxy.tasking_manager.models import ValidatorStatsRequest | ||
from src.galaxy.app import TaskingManager | ||
|
||
from fastapi.responses import StreamingResponse | ||
|
||
from datetime import datetime | ||
|
||
|
||
router = APIRouter(prefix="/tasking-manager") | ||
|
||
@router.post("/validators") | ||
def get_validator_stats(request: ValidatorStatsRequest): | ||
tm = TaskingManager(request) | ||
csv_stream = tm.get_validators_stats() | ||
|
||
response = StreamingResponse(csv_stream) | ||
name =f"ValidatorStats_{datetime.now().isoformat()}" | ||
response.headers["Content-Disposition"] = f"attachment; filename={name}.csv" | ||
|
||
return response | ||
|
||
|
||
@router.get("/teams") | ||
def get_teams(): | ||
csv_stream = TaskingManager().list_teams() | ||
|
||
response = StreamingResponse(csv_stream) | ||
name =f"Teams_{datetime.now().isoformat()}" | ||
response.headers["Content-Disposition"] = f"attachment; filename={name}.csv" | ||
|
||
return response | ||
|
||
|
||
@router.get("/teams/individual") | ||
def get_teams(): | ||
csv_stream = TaskingManager().list_teams_metadata() | ||
|
||
response = StreamingResponse(csv_stream) | ||
name =f"Teams_{datetime.now().isoformat()}" | ||
response.headers["Content-Disposition"] = f"attachment; filename={name}.csv" | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from ..validation.models import BaseModel | ||
from typing import Optional | ||
|
||
|
||
class ValidatorStatsRequest(BaseModel): | ||
year: int = 2012 | ||
country: Optional[str] = None | ||
organisation: Optional[str] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters