Show More
@@ -0,0 +1,28 b'' | |||
|
1 | from django.core.management import BaseCommand | |
|
2 | ||
|
3 | from boards.models import Attachment | |
|
4 | from boards.utils import get_domain | |
|
5 | ||
|
6 | ||
|
7 | class Command(BaseCommand): | |
|
8 | help = 'Gather board statistics' | |
|
9 | ||
|
10 | def handle(self, *args, **options): | |
|
11 | domains = {} | |
|
12 | for attachment in Attachment.objects.exclude(url=None): | |
|
13 | full_domain = attachment.url.split('/')[2] | |
|
14 | domain = get_domain(full_domain) | |
|
15 | if domain in domains: | |
|
16 | domains[domain] += 1 | |
|
17 | else: | |
|
18 | domains[domain] = 1 | |
|
19 | ||
|
20 | print('* Domains and their usage') | |
|
21 | for domain in domains: | |
|
22 | print('{}: {}'.format(domain, domains[domain])) | |
|
23 | ||
|
24 | print('* Overall numbers') | |
|
25 | print('{} attachments in the system, {} of them as URLs'.format( | |
|
26 | Attachment.objects.count(), | |
|
27 | Attachment.objects.exclude(url=None).count())) | |
|
28 |
General Comments 0
You need to be logged in to leave comments.
Login now