Eine Menge Aufräumarbeiten.
* Eine Testsuite um Mahrjong Ranking Berechnungen zu testen * Erste Arbeiten um die Workarounds aus dem "utils" Paket los zu werden. * Vieles am Code umformatiert für PEP8 conformität
This commit is contained in:
@@ -10,31 +10,32 @@ from mahjong_ranking.models import SeasonRanking
|
||||
from openpyxl import Workbook
|
||||
|
||||
|
||||
def geneate_seasonexcel(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:
|
||||
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")
|
||||
|
||||
|
||||
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:
|
||||
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)
|
||||
geneate_seasonexcel(season_json)
|
||||
|
||||
@@ -14,4 +14,3 @@ class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
for ranking in models.KyuDanRanking.objects.all():
|
||||
ranking.recalculate()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user