##// END OF EJS Templates
Added statistics management command
neko259 -
r1727:2927138c default
parent child Browse files
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
@@ -11,6 +11,7 b' from boards.utils import get_domain'
11 FILE_STUB_IMAGE = 'images/file.png'
11 FILE_STUB_IMAGE = 'images/file.png'
12 FILE_STUB_URL = 'url'
12 FILE_STUB_URL = 'url'
13
13
14
14 FILE_TYPES_VIDEO = (
15 FILE_TYPES_VIDEO = (
15 'webm',
16 'webm',
16 'mp4',
17 'mp4',
General Comments 0
You need to be logged in to leave comments. Login now