Show More
@@ -1,4 +1,5 b'' | |||
|
1 | 1 | from django.core.management import BaseCommand |
|
2 | from django.db.models import Count | |
|
2 | 3 | |
|
3 | 4 | from boards.models import Attachment |
|
4 | 5 | from boards.utils import get_domain |
@@ -8,6 +9,7 b' class Command(BaseCommand):' | |||
|
8 | 9 | help = 'Gather board statistics' |
|
9 | 10 | |
|
10 | 11 | def handle(self, *args, **options): |
|
12 | print('* Domains and their usage') | |
|
11 | 13 | domains = {} |
|
12 | 14 | for attachment in Attachment.objects.exclude(url=None): |
|
13 | 15 | full_domain = attachment.url.split('/')[2] |
@@ -17,7 +19,6 b' class Command(BaseCommand):' | |||
|
17 | 19 | else: |
|
18 | 20 | domains[domain] = 1 |
|
19 | 21 | |
|
20 | print('* Domains and their usage') | |
|
21 | 22 | for domain in domains: |
|
22 | 23 | print('{}: {}'.format(domain, domains[domain])) |
|
23 | 24 | |
@@ -26,3 +27,9 b' class Command(BaseCommand):' | |||
|
26 | 27 | Attachment.objects.count(), |
|
27 | 28 | Attachment.objects.exclude(url=None).count())) |
|
28 | 29 | |
|
30 | print('* File types') | |
|
31 | mimetypes = Attachment.objects.filter(url=None)\ | |
|
32 | .values('mimetype').annotate(count=Count('id'))\ | |
|
33 | .order_by('-count') | |
|
34 | for mimetype in mimetypes: | |
|
35 | print('{}: {}'.format(mimetype['mimetype'], mimetype['count'])) |
General Comments 0
You need to be logged in to leave comments.
Login now