Browse Source

Update progress

pull/10/head
Hironsan 6 years ago
parent
commit
830fdc42e8
5 changed files with 30 additions and 7 deletions
  1. BIN
      doccano/app/db.sqlite3
  2. 9
      doccano/app/server/static/annotation.js
  3. 13
      doccano/app/server/static/project_admin.js
  4. 4
      doccano/app/server/urls.py
  5. 11
      doccano/app/server/views.py

BIN
doccano/app/db.sqlite3

9
doccano/app/server/static/annotation.js

@ -176,6 +176,15 @@ var vm = new Vue({
console.log('ERROR!! happend by Backend.') 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') axios.get('/' + base_url + '/apis/data')
.then(function (response) { .then(function (response) {
self.items = response.data['data']; self.items = response.data['data'];

13
doccano/app/server/static/project_admin.js

@ -23,6 +23,8 @@ var vm = new Vue({
editedTodo: null, editedTodo: null,
newLabel: '', newLabel: '',
newShortcut: '', newShortcut: '',
total: 0,
remaining: 0,
}, },
methods: { methods: {
@ -120,6 +122,17 @@ var vm = new Vue({
.catch(function (error) { .catch(function (error) {
console.log('ERROR!! happend by Backend.') 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: { directives: {
'todo-focus': function (el, binding) { 'todo-focus': function (el, binding) {

4
doccano/app/server/urls.py

@ -1,6 +1,6 @@
from django.urls import path 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 from .views import ProjectListView, ProjectAdminView, RawDataAPI, LabelAPI
urlpatterns = [ urlpatterns = [
@ -10,6 +10,6 @@ urlpatterns = [
path('<int:project_id>/apis/data', AnnotationAPIView.as_view()), path('<int:project_id>/apis/data', AnnotationAPIView.as_view()),
path('<int:pk>/apis/raw_data', RawDataAPI.as_view(), name='data_api'), path('<int:pk>/apis/raw_data', RawDataAPI.as_view(), name='data_api'),
path('<int:pk>/apis/labels', LabelAPI.as_view(), name='label_api'), path('<int:pk>/apis/labels', LabelAPI.as_view(), name='label_api'),
path('<int:project_id>/apis/label', MetaInfoAPI.as_view()),
path('<int:project_id>/apis/progress', ProgressAPI.as_view()),
path('<int:project_id>/apis/search', SearchAPI.as_view()), path('<int:project_id>/apis/search', SearchAPI.as_view()),
] ]

11
doccano/app/server/views.py

@ -56,11 +56,14 @@ class AnnotationAPIView(View):
return JsonResponse({}) return JsonResponse({})
class MetaInfoAPI(View):
class ProgressAPI(View):
def get(self, request, *args, **kwargs): 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}) return JsonResponse({'total': total, 'remaining': remaining})
@ -71,8 +74,6 @@ class SearchAPI(View):
keyword = request.GET.get('keyword') keyword = request.GET.get('keyword')
docs = Document.objects.filter(text__contains=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] 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] docs = [{**d.as_dict(), **{'labels': []}} for d in docs]
# Annotation.objects.select_related('data').all().filter(data__text__contains=keyword) # Annotation.objects.select_related('data').all().filter(data__text__contains=keyword)

Loading…
Cancel
Save