From 4dd4e2e19a21ec96382b267e354a165c180bca13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Tue, 12 Jul 2016 19:27:12 +0200 Subject: [PATCH] Supprime `tirage_bda.py` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ce script devait servir simuler un tirage. Ça ne semble rien apporter, sutout dans la mesure où il ne peut être lancé que par les personnes ayant accès à la machine COF. --- tirage_bda.py | 66 --------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 tirage_bda.py diff --git a/tirage_bda.py b/tirage_bda.py deleted file mode 100644 index 502cb45e..00000000 --- a/tirage_bda.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 -import os -import sys -import time - -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings") - from django.conf import settings - settings.DEBUG = True - from bda.models import Spectacle, Participant, ChoixSpectacle - from bda.algorithm import Algorithm - from django.db.models import Sum - from django.db import connection - start = time.time() - shows = Spectacle.objects.all() - members = Participant.objects.all() - choices = ChoixSpectacle.objects.order_by('participant', 'priority') \ - .select_related().all() - available_slots = Spectacle.objects.aggregate(Sum('slots'))['slots__sum'] - cursor = connection.cursor() - cursor.execute( - "SELECT SUM(`slots` * `price`) AS `total` FROM `bda_spectacle`;") - total_price = cursor.fetchone()[0] - print "%d spectacles" % len(shows) - print "%d places" % available_slots - print "%d participants" % len(members) - print "%d demandes" % len(choices) - print "%d places demandées" % (len(choices) - + len(choices.filter(double=True).all())) - print "%.02f€ à brasser" % total_price - print "Récupération: %.2fs" % (time.time() - start) - start_init = time.time() - algo = Algorithm(shows, members, choices) - print "Initialisation: %.2fs" % (time.time() - start_init) - start_algo = time.time() - results = algo(sys.argv[1]) - print "Traitement: %.2fs" % (time.time() - start_algo) - print len(connection.queries), "requêtes SQL effectuées" - queries = list(connection.queries) - total_slots = 0 - total_losers = 0 - for (_, members, losers) in results: - total_slots += len(members) - total_losers += len(losers) - print "Placés %d\nDécus %d" % (total_slots, total_losers) - print "Total %d" % (total_slots + total_losers) - members2 = {} - members_uniq = {} - for (show, members, _) in results: - for (member, _, _, _) in members: - if member.id not in members_uniq: - members_uniq[member.id] = member - members2[member] = [] - member.total = 0 - member = members_uniq[member.id] - members2[member].append(show) - member.total += show.price - if len(members) < show.slots: - print "%d place(s) invendue(s) pour %s" \ - % (show.slots - len(members), show) - members2 = members2.items() - print "Temps total: %.2fs" % (time.time() - start) - print "Requêtes SQL:" - for query in queries: - print query['sql']