diff --git a/doccano/app/db.sqlite3 b/doccano/app/db.sqlite3 index 26bddf1c..3eae58d5 100644 Binary files a/doccano/app/db.sqlite3 and b/doccano/app/db.sqlite3 differ diff --git a/doccano/app/server/static/annotation.js b/doccano/app/server/static/annotation.js index c6493996..7a4d3b8b 100644 --- a/doccano/app/server/static/annotation.js +++ b/doccano/app/server/static/annotation.js @@ -176,6 +176,15 @@ var vm = new Vue({ console.log('ERROR!! happend by Backend.') }); + axios.get('/' + base_url + '/apis/progress') + .then(function (response) { + self.total = response.data['total']; + self.remaining = response.data['remaining']; + }) + .catch(function (error) { + console.log('ERROR!! happend by Backend.') + }); + axios.get('/' + base_url + '/apis/data') .then(function (response) { self.items = response.data['data']; diff --git a/doccano/app/server/static/project_admin.js b/doccano/app/server/static/project_admin.js index 0e370c2f..e38b248c 100644 --- a/doccano/app/server/static/project_admin.js +++ b/doccano/app/server/static/project_admin.js @@ -23,6 +23,8 @@ var vm = new Vue({ editedTodo: null, newLabel: '', newShortcut: '', + total: 0, + remaining: 0, }, methods: { @@ -120,6 +122,17 @@ var vm = new Vue({ .catch(function (error) { console.log('ERROR!! happend by Backend.') }); + axios.get('/' + base_url + '/apis/progress') + .then(function (response) { + console.log(response.data); + self.total = response.data['total']; + self.remaining = response.data['remaining']; + console.log(self.total); + console.log(self.remaining); + }) + .catch(function (error) { + console.log('ERROR!! happend by Backend.') + }); }, directives: { 'todo-focus': function (el, binding) { diff --git a/doccano/app/server/urls.py b/doccano/app/server/urls.py index 2b504ae9..a36b34ef 100644 --- a/doccano/app/server/urls.py +++ b/doccano/app/server/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from .views import AnnotationView, AnnotationAPIView, MetaInfoAPI, SearchAPI +from .views import AnnotationView, AnnotationAPIView, ProgressAPI, SearchAPI from .views import ProjectListView, ProjectAdminView, RawDataAPI, LabelAPI urlpatterns = [ @@ -10,6 +10,6 @@ urlpatterns = [ path('/apis/data', AnnotationAPIView.as_view()), path('/apis/raw_data', RawDataAPI.as_view(), name='data_api'), path('/apis/labels', LabelAPI.as_view(), name='label_api'), - path('/apis/label', MetaInfoAPI.as_view()), + path('/apis/progress', ProgressAPI.as_view()), path('/apis/search', SearchAPI.as_view()), ] diff --git a/doccano/app/server/views.py b/doccano/app/server/views.py index 51ceac01..a4a33e35 100644 --- a/doccano/app/server/views.py +++ b/doccano/app/server/views.py @@ -56,11 +56,14 @@ class AnnotationAPIView(View): return JsonResponse({}) -class MetaInfoAPI(View): +class ProgressAPI(View): def get(self, request, *args, **kwargs): - total = Document.objects.count() - remaining = Document.objects.filter(annotation__isnull=True).count() + project_id = kwargs.get('project_id') + project = Project.objects.get(id=project_id) + docs = Document.objects.filter(project=project) + total = docs.count() + remaining = docs.filter(annotation__isnull=True).count() return JsonResponse({'total': total, 'remaining': remaining}) @@ -71,8 +74,6 @@ class SearchAPI(View): keyword = request.GET.get('keyword') docs = Document.objects.filter(text__contains=keyword) labels = [[a.as_dict() for a in Annotation.objects.filter(data=d.id)] for d in docs] - # print(annotations) - # print(docs) docs = [{**d.as_dict(), **{'labels': []}} for d in docs] # Annotation.objects.select_related('data').all().filter(data__text__contains=keyword)