From 75610eb2652302a188a332c0d54ef4ba0880e5ff Mon Sep 17 00:00:00 2001 From: Tom Searle Date: Wed, 11 Oct 2023 21:30:44 +0100 Subject: [PATCH 1/4] CU-8692wrwbb: show how many docs completed and left to go. --- webapp/api/api/views.py | 20 +++++++++++ webapp/api/core/urls.py | 1 + webapp/frontend/src/views/Home.vue | 53 +++++++++++++++++++++++++++++- 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/webapp/api/api/views.py b/webapp/api/api/views.py index 162cf4eb..737f6e62 100644 --- a/webapp/api/api/views.py +++ b/webapp/api/api/views.py @@ -734,3 +734,23 @@ def generate_concept_filter(request): resp['filter'] = final_filter return Response(resp) return HttpResponseBadRequest('Missing either cuis or cdb_id param. Cannot generate filter.') + + +@api_view(http_method_names=['GET']) +def project_progress(request): + projects = [int(p) for p in request.GET.get('projects', []).split(',')] + + projects2datasets = {p.id: (p, p.dataset) for p in [ProjectAnnotateEntities.objects.filter(id=p_id).first() + for p_id in projects]} + + out = {} + ds_doc_counts = {} + for p, (proj, ds) in projects2datasets.items(): + val_docs = proj.validated_documents.count() + ds_doc_count = ds_doc_counts.get(ds.id) + if ds_doc_count is None: + ds_doc_count = Document.objects.filter(dataset=ds).count() + ds_doc_counts[ds.id] = ds_doc_count + out[p] = {'validated_count': val_docs, 'dataset_count': ds_doc_count} + + return Response(out) diff --git a/webapp/api/core/urls.py b/webapp/api/core/urls.py index 9eda1ce7..43e73e1f 100644 --- a/webapp/api/core/urls.py +++ b/webapp/api/core/urls.py @@ -57,6 +57,7 @@ path('api/download-annos/', api.views.download_annos), path('api/behind-rp/', api.views.behind_reverse_proxy), path('api/version/', api.views.version), + path('api/project-progress/', api.views.project_progress), path('api/concept-db-search-index-created/', api.views.concept_search_index_available), path('api/model-loaded/', api.views.model_loaded), path('api/cache-model//', api.views.cache_model), diff --git a/webapp/frontend/src/views/Home.vue b/webapp/frontend/src/views/Home.vue index 28496155..ec5eefc7 100644 --- a/webapp/frontend/src/views/Home.vue +++ b/webapp/frontend/src/views/Home.vue @@ -115,6 +115,9 @@ +
@@ -172,7 +175,8 @@ export default { { key: 'create_time', label: 'Create Time', sortable: true }, { key: 'cuis', label: 'Concepts' }, { key: 'require_entity_validation', label: 'Annotate / Validate' }, - { key: 'status', label: 'Status' }, + { key: 'status', label: 'Status', sortable: true }, + { key: 'progress', label: 'Progress', formatter: this.progressFormatter }, { key: 'anno_class', label: 'Annotation Classification'}, { key: 'cdb_search_filter', label: 'Concepts Imported' }, { key: 'model_loaded', label: 'Model Loaded' }, @@ -268,6 +272,7 @@ export default { postLoadedProjects () { this.fetchCDBsLoaded() this.fetchSearchIndexStatus() + this.fetchProjectProgress() this.loadingProjects = false }, fetchCDBsLoaded () { @@ -321,6 +326,16 @@ export default { console.log(err) }) }, + fetchProjectProgress () { + const projectIds = this.projects.items.map(p => p.id) + this.$http.get(`/api/project-progress/?projects=${projectIds}`).then(resp => { + this.projects.items = this.projects.items.map(item => { + item['progress'] = `${resp.data[item.id].validated_count} / ${resp.data[item.id].dataset_count}` + item['percent_progress'] = Math.ceil((resp.data[item.id].validated_count / resp.data[item.id].dataset_count) * 100) + return item + }) + }) + }, select (projects) { let project = projects[0] if (!project.project_locked) { @@ -358,6 +373,19 @@ export default { that.modelSavedError = false }, 5000) }) + }, + progressFormatter (value, key, item) { + let txtColorClass = 'good-perf' + if (item['percent_progress'] < 45) { + txtColorClass = 'bad-perf' + } + return ` +
+ ${value} +
+
+ + ` } } } @@ -447,4 +475,27 @@ h3 { padding: 0 5px; } +.progress-container { + position: relative; + padding-left: 2px; +} + +.gradient-fill { + position: absolute; + z-index: -1; + top: 0; + height: 25px; + padding: 0 1px; + background-image: linear-gradient(to right, #32ab60, #E8EDEE); + box-shadow: 0 5px 5px -5px #32ab60; +} + +.good-perf { + color: #E5EBEA; +} + +.bad-perf { + color: #45503B; +} + From 569521c7ac75503e2774b2798aeb25bb42dfdcff Mon Sep 17 00:00:00 2001 From: Tom Searle Date: Thu, 12 Oct 2023 00:18:01 +0100 Subject: [PATCH 2/4] CU-8692wrwbb: show how many docs completed and are left to go --- webapp/frontend/src/views/Home.vue | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/webapp/frontend/src/views/Home.vue b/webapp/frontend/src/views/Home.vue index ec5eefc7..2f9bd9bf 100644 --- a/webapp/frontend/src/views/Home.vue +++ b/webapp/frontend/src/views/Home.vue @@ -46,8 +46,8 @@ + +