Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CloWM Workflow Service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Computational Metagenomics
CloWM
CloWM Workflow Service
Merge requests
!30
Resolve "Workflow usage statistics"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Workflow usage statistics"
feature/24-workflow-usage-statistics
into
development
Overview
0
Commits
2
Pipelines
3
Changes
5
Merged
Daniel Göbel
requested to merge
feature/24-workflow-usage-statistics
into
development
1 year ago
Overview
0
Commits
2
Pipelines
3
Changes
5
Expand
Closes
#24 (closed)
0
0
Merge request reports
Compare
development
version 1
68b6beda
1 year ago
development (base)
and
latest version
latest version
c8b5d24e
2 commits,
1 year ago
version 1
68b6beda
1 commit,
1 year ago
5 files
+
125
−
14
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
app/api/endpoints/workflow.py
+
31
−
3
Options
from
typing
import
Annotated
,
Any
,
Awaitable
,
Callable
from
clowmdb.models
import
Workflow
,
WorkflowVersion
from
fastapi
import
APIRouter
,
BackgroundTasks
,
Depends
,
File
,
HTTPException
,
Query
,
UploadFile
,
status
from
fastapi
import
APIRouter
,
BackgroundTasks
,
Depends
,
File
,
HTTPException
,
Query
,
Response
,
UploadFile
,
status
from
app.api.dependencies
import
AuthorizationDependency
,
CurrentUser
,
CurrentWorkflow
,
DBSession
,
HTTPClient
,
S3Service
from
app.api.utils
import
check_repo
,
upload_icon
from
app.core.config
import
settings
from
app.crud
import
CRUDWorkflow
,
CRUDWorkflowVersion
from
app.git_repository
import
build_repository
from
app.schemas.workflow
import
WorkflowIn
,
WorkflowOut
from
app.schemas.workflow
import
WorkflowIn
,
WorkflowOut
,
WorkflowStatistic
from
app.schemas.workflow_version
import
WorkflowVersionFull
,
WorkflowVersionUpdate
router
=
APIRouter
(
prefix
=
"
/workflows
"
,
tags
=
[
"
Workflow
"
])
@@ -72,7 +72,7 @@ async def list_workflows(
rbac_operation
=
"
list_filter
"
await
authorization
(
rbac_operation
)
workflows
:
list
[
Workflow
]
=
await
CRUDWorkflow
.
list
(
workflows
:
list
[
Workflow
]
=
await
CRUDWorkflow
.
list
_workflows
(
db
,
name_substring
=
name_substring
,
developer_id
=
developer_id
,
@@ -205,6 +205,34 @@ async def get_workflow(
return
WorkflowOut
.
from_db_workflow
(
workflow
,
versions
)
@router.get
(
"
/{wid}/statistics
"
,
status_code
=
status
.
HTTP_200_OK
,
summary
=
"
Get statistics for a workflow
"
)
async
def
get_workflow_statistics
(
workflow
:
CurrentWorkflow
,
db
:
DBSession
,
authorization
:
Authorization
,
response
:
Response
)
->
list
[
WorkflowStatistic
]:
"""
Get the number of started workflow per day.
\f
Parameters
----------
workflow : clowmdb.models.Workflow
Workflow with given ID. Dependency Injection.
db : sqlalchemy.ext.asyncio.AsyncSession.
Async database session to perform query on. Dependency Injection.
authorization : Callable[[str], Awaitable[Any]]
Async function to ask the auth service for authorization. Dependency Injection.
response : fastapi.Response
Temporal Response object. Dependency Injection.
Returns
-------
statistics : list[app.schema.Workflow.WorkflowStatistic]
"""
await
authorization
(
"
read
"
)
# Instruct client to cache response for 1 hour
response
.
headers
[
"
Cache-Control
"
]
=
"
max-age=3600
"
return
await
CRUDWorkflow
.
statistics
(
db
,
workflow
.
workflow_id
)
@router.delete
(
"
/{wid}
"
,
status_code
=
status
.
HTTP_204_NO_CONTENT
,
summary
=
"
Delete a workflow
"
)
async
def
delete_workflow
(
background_tasks
:
BackgroundTasks
,
Loading