Commit 721221ba authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

report

parent d6ea5710
from django.core.management.base import BaseCommand, CommandError
from catalog.models import User, News, Publisher, Topic, audioTime
from django.db.models import Q
import os
import json
class Command(BaseCommand):
help = 'Report database'
# def add_arguments(self, parser):
# parser.add_argument('basedir', nargs=1, type=str) #(options['basedir'][0]
def handle(self, *args, **options):
print ( "Users: " + str(User.objects.all().count()) )
print ( "Publishers: " + str(Publisher.objects.all().count()) )
print ( "\tText: " + str(Publisher.objects.all().filter(type="texto").count()) )
print ( "\t\tDocuments: " + "{:,}".format(News.objects.all().count()) )
print ( "\tAudio: " + str(Publisher.objects.all().filter(type="audio").count()) )
minutes = sum([a.minutes for a in audioTime.objects.all()])
print ( "\t\tRecorders hours: " + "{:,}".format(minutes/60.) )
print("=======================================================")
textSources = Publisher.objects.all().filter(type="texto")
for t in textSources:
print(t.name + ", " + t.url + ", " + str(News.objects.all().filter(publisher=t).count()) )
print("=======================================================")
audioSources = Publisher.objects.all().filter(type="audio")
for a in audioSources:
print(a.name + ", " + a.url + ", " + str(audioTime.objects.all().filter(publisher=a)[0].minutes ))
...@@ -18,7 +18,7 @@ class Command(BaseCommand): ...@@ -18,7 +18,7 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
if False: if True:
#update radio stations recotding time #update radio stations recotding time
print("Recording Time:") print("Recording Time:")
recordingsDir = "/home/mario/virtualHDD/m3/recordings/" recordingsDir = "/home/mario/virtualHDD/m3/recordings/"
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment