49d41416e440926f0a9a8243b4d77f6f5468efe9,app/server/api.py,StatisticsAPI,label_per_data,#StatisticsAPI#Any#,63

Before Change


        for doc in project.documents.all():
            annotations = annotation_class.objects.filter(document=doc.id)
            for a in annotations:
                label_count[a.label.text] += 1
                user_count[a.user.username] += 1
        return label_count, user_count

After Change


        annotation_class = project.get_annotation_class()
        docs = project.documents.all()
        annotations = annotation_class.objects.filter(document_id__in=docs.all())
        for d in annotations.values("label__text", "user__username").annotate(Count("label"), Count("user")):
            label_count[d["label__text"]] += d["label__count"]
            user_count[d["user__username"]] += d["user__count"]
        return label_count, user_count


class LabelList(generics.ListCreateAPIView):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: chakki-works/doccano
Commit Name: 49d41416e440926f0a9a8243b4d77f6f5468efe9
Time: 2019-03-12
Author: light.tree.1.13@gmail.com
File Name: app/server/api.py
Class Name: StatisticsAPI
Method Name: label_per_data


Project Name: AlexsLemonade/refinebio
Commit Name: 86fa89f0f50e153d625108d93f1f9eb8ee59719e
Time: 2019-11-01
Author: davidsmejia@gmail.com
File Name: workers/data_refinery_workers/processors/create_compendia.py
Class Name:
Method Name: _create_result_objects


Project Name: chakki-works/doccano
Commit Name: 6455754bfab4de7670e4c9cd889e85f5dfccce34
Time: 2019-07-11
Author: federica.nocera@gmail.com
File Name: app/api/views.py
Class Name: StatisticsAPI
Method Name: label_per_data