Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added api call for submissions per team and added team-review table t… #611

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion application/src/tira/data/HybridDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from tira.util import TiraModelWriteError, TiraModelIntegrityError
from tira.proto import TiraClientWebMessages_pb2 as modelpb
from tira.util import auto_reviewer, now, get_today_timestamp, get_tira_id
from tira.util import auto_reviewer, now, get_today_timestamp, get_tira_id, link_to_discourse_team

import tira.model as modeldb
import tira.data.data as dbops
Expand Down Expand Up @@ -668,6 +668,35 @@ def get_count_of_missing_reviews(self, task_id):

return ret

def get_count_of_team_submissions(self, task_id):
prepared_statement = """
SELECT
tira_dockersoftware.vm_id as vm,
SUM(CASE WHEN tira_review.has_errors = False AND tira_review.has_no_errors = FALSE AND tira_review.has_warnings = FALSE THEN 1 ELSE 0 END) as ToReview,
COUNT(*) - SUM(CASE WHEN tira_review.has_errors = False AND tira_review.has_no_errors = FALSE AND tira_review.has_warnings = FALSE THEN 1 ELSE 0 END) as submissions,
COUNT(*) as total
FROM
tira_run
INNER JOIN
tira_taskhasdataset ON tira_run.input_dataset_id = tira_taskhasdataset.dataset_id
LEFT JOIN
tira_review ON tira_run.run_id = tira_review.run_id
LEFT JOIN
tira_dockersoftware ON tira_run.docker_software_id = tira_dockersoftware.docker_software_id
WHERE
tira_taskhasdataset.task_id = %s
GROUP BY
tira_dockersoftware.vm_id;
"""

ret = []
rows = self.execute_raw_sql_statement(prepared_statement, params=[task_id])
for vm, to_review, submissions, total in rows:
if vm is not None:
ret += [{'team': vm, 'reviewed': submissions, 'to_review': to_review, 'total': total, 'link': link_to_discourse_team(vm)}]
print(ret)
return ret

def runs(self, task_id, dataset_id, vm_id, software_id):
prepared_statement = """
SELECT
Expand Down
7 changes: 7 additions & 0 deletions application/src/tira/endpoints/organizer_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ def blind(request, vm_id, dataset_id, run_id, value):
def get_count_of_missing_reviews(request, task_id):
context = {"count_of_missing_reviews": model.get_count_of_missing_reviews(task_id)}
return JsonResponse({"status": 0, "context": context})


@check_permissions
@check_resources_exist('json')
def get_count_of_team_submissions(request, task_id):
context = {"count_of_team_submissions": model.get_count_of_team_submissions(task_id)}
return JsonResponse({"status": 0, "context": context})
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<loading :loading="loading"/>
<v-data-table v-if="!loading" :headers="table_headers" :items="count_of_team_submissions" density="compact">
<template v-slot:item="row">
<tr>
<td>{{row.item.team}}</td>
<td>{{row.item.reviewed}}</td>
<td>{{row.item.to_review}}</td>
<td>{{row.item.total}}</td>
<td>
<a :href="row.item.link">
link to {{row.item.team}}`s page
</a>
</td>
</tr>
</template>
</v-data-table>
</template>

<script lang="ts">
import { Loading } from '.'
import { get, reportError, inject_response} from '../utils'

interface CountOfTeamSubmissions {
team: string,
reviewed: number,
to_review: number,
total: number,
link: string

}

export default {
name: "overview-team-submissions",
components: {Loading},
props: ['task'],
data() { return {
loading: true,
count_of_team_submissions:[] as CountOfTeamSubmissions[],
table_headers: [
{ title: 'Team', key: 'team' },
{ title: 'Reviewed Submissions', key: 'reviewed' },
{ title: 'To review', key: 'to_review' },
{ title: 'Total', key: 'total' },
{ title: 'Team Page', key: 'link' }
],
}},
beforeMount() {
this.loading = true
get('/api/count-of-team-submissions/' + this.task.task_id)
.then(inject_response(this, {'loading': false}))
.catch(reportError("Problem While Loading the Overview of Submissions per Team", "This might be a short-term hiccup, please try again. We got the following error: "))
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
<overview-missing-reviews :task="task" />
</v-expansion-panel-text>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-title>Overview Team Submissions</v-expansion-panel-title>
<v-expansion-panel-text>
<overview-team-submissions :task="task" />
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansion-panels>
</v-container>
</template>
Expand All @@ -61,13 +67,14 @@
import { extractTaskFromCurrentUrl, extractRole, get, reportError, reportSuccess } from '../utils'
import {VAutocomplete} from "vuetify/components";
import OverviewMissingReviews from './OverviewMissingReviews.vue';
import OverviewTeamSubmissions from './OverviewTeamSubmissions.vue';
import EditTask from './EditTask.vue';
import EditDataset from './EditDataset.vue';
import ConfirmDelete from './ConfirmDelete.vue';

export default {
name: "tira-task-admin",
components: {OverviewMissingReviews, EditTask, VAutocomplete, EditDataset, ConfirmDelete},
components: {OverviewMissingReviews, OverviewTeamSubmissions, EditTask, VAutocomplete, EditDataset, ConfirmDelete},
props: ['datasets', 'task'],
emits: ['add-dataset', 'delete-dataset'],
data() {
Expand Down
2 changes: 1 addition & 1 deletion application/src/tira/frontend-vuetify/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,4 @@ export function handleModifiedSubmission(modified_data: any, objects: Array<any>
}

return objects
}
}
3 changes: 3 additions & 0 deletions application/src/tira/tira_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ def get_evaluation(run_id: str):
def get_count_of_missing_reviews(task_id):
return model.get_count_of_missing_reviews(task_id)

def get_count_of_team_submissions(task_id):
return model.get_count_of_team_submissions(task_id)


def get_software_with_runs(task_id, vm_id):
"""
Expand Down
1 change: 1 addition & 0 deletions application/src/tira/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
path('api/role', data_api.get_role, name='get_role'),
path('api/task/<str:task_id>/user/<str:user_id>', data_api.get_user, name='get_user'),
path('api/task/<str:task_id>/user/<str:user_id>/refresh-docker-images', data_api.update_docker_images, name="get_updated_docker_images"),
path('api/count-of-team-submissions/<str:task_id>', organizer_api.get_count_of_team_submissions, name='get_count_of_team_submissions'),
path('api/count-of-missing-reviews/<str:task_id>', organizer_api.get_count_of_missing_reviews, name='get_count_of_missing_reviews'),
path('api/task/<str:task_id>/user/<str:user_id>/software/running/<str:force_cache_refresh>', data_api.get_running_software, name='get_running_software'),
path('api/task/<str:task_id>/public-submissions', data_api.public_submissions, name='public_submissions'),
Expand Down
Loading