-
Notifications
You must be signed in to change notification settings - Fork 32
/
set_match_cache.py
24 lines (20 loc) · 1013 Bytes
/
set_match_cache.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# coding=utf-8
from django.core.management.base import BaseCommand, CommandError
from merepresenta.match.matrix_builder import MatrixBuilder
from elections.models import Election
from popular_proposal.models import PopularProposal
from popular_proposal.replicator import Replicator
from merepresenta.tse_processor import TSEProcessor
from django.core.cache import cache
class Command(BaseCommand):
help = u'Carga caché del match de merepresenta, esto es para que el match no toque la DB'
def add_arguments(self, parser):
parser.add_argument('time', type=int, default=7200, nargs="*")
def handle(self, *args, **options):
time = options['time'][0]
builder = MatrixBuilder(time=time)
cache.set(builder.cache_key, None)
cache.set(builder.cache_key_candidates_right_positions, None)
r = builder.get_candidates_result()
shape = r.shape
self.stdout.write("Saved matrix of %d candidates with answers, for %d minutes" % (shape[0], time/60))