Fehler bei Vergabe von Bonuspunkte korrigiert.
Kommentare für Bonuspunkte werden jetzt als Kommentar beim Spieler hinterlassen, nicht als Kommentar in der Hanchan. FIXED: 3_in_a_row counter wurde nicht zurückgesetzt wenn Bonuspunkte vergeben wurden. FIXED: Durchschnittliche Platzierung während eines Events wurde nur als Ganzzahl berechnet. Wird nun als Fießkomma berechnet und gesichert.
This commit is contained in:
41
src/mahjong_ranking/management/commands/export-ranking.py
Normal file
41
src/mahjong_ranking/management/commands/export-ranking.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Export Mahjong Rankings...
|
||||
"""
|
||||
|
||||
from operator import itemgetter
|
||||
from django.core.management.base import BaseCommand
|
||||
from mahjong_ranking.models import SeasonRanking
|
||||
from openpyxl import Workbook
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Exports the SeasonRankings"
|
||||
|
||||
def geneate_seasonexcel(self, json_data):
|
||||
|
||||
wb = Workbook()
|
||||
worksheet = wb.active
|
||||
|
||||
worksheet.append([
|
||||
'Rang', 'Spitzname',
|
||||
'⌀ Platz', '⌀ Punkte',
|
||||
'Hanchans', 'Gut', 'Gewonnen'
|
||||
])
|
||||
|
||||
json_data = json_data.values()
|
||||
json_data = sorted(json_data, key=itemgetter('placement'))
|
||||
for row in json_data:
|
||||
print row
|
||||
worksheet.append([
|
||||
row['placement'], row['username'],
|
||||
row['avg_placement'], row['avg_score'],
|
||||
row['hanchan_count'],
|
||||
row['good_hanchans'], row['won_hanchans']
|
||||
])
|
||||
wb.save("sample.xlsx")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
season_json = SeasonRanking.objects.json_data()
|
||||
self.geneate_seasonexcel(season_json)
|
||||
@@ -85,7 +85,6 @@ class Command(BaseCommand):
|
||||
self.add_players(hanchan)
|
||||
hanchan.save()
|
||||
|
||||
|
||||
def handle(self, *args, **options):
|
||||
num_hanchans = int(options.get('hanchans', 4))
|
||||
self.user_list = list(auth.get_user_model().objects.all())
|
||||
@@ -93,5 +92,3 @@ class Command(BaseCommand):
|
||||
for event in Event.objects.all():
|
||||
for i in range(random.randrange(2, 8)):
|
||||
self.create_hanchan(event)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user