Changeset - 1765f32cd4dc
[Not reviewed]
default
0 1 0
Laman - 7 years ago 2018-04-01 14:11:49

populationAge rozšířen na rozsah let
1 file changed with 23 insertions and 10 deletions:
queries.py
23
10
0 comments (0 inline, 0 general)
queries.py
Show inline comments
 
@@ -109,14 +109,14 @@ def populationStrength(year1,year2,count
 
		print("\r",year,end="",file=sys.stderr)
 
	print("\r",end="",file=sys.stderr)
 

	
 
	print("Počty aktivních hráčů v {0} s uvedeným  vyšším ratingem".format(country))
 
	print("Počty aktivních hráčů v {0} s uvedeným a vyšším ratingem".format(country))
 
	print("rating\t"+"\t".join(str(y) for y in range(year1,year2)))
 
	for rating in sorted(res.keys()):
 
		print(rating,end="\t")
 
		print("\t".join(str(res[rating].get(y,0)) for y in range(year1,year2)))
 

	
 

	
 
def populationAge(year,country):
 
def _populationAge(year,country):
 
	"""Rozdělení populace země v daném roce podle doby hraní (celých let od prvního turnaje). Uvažují se pouze aktivní hráči."""
 
	date1=yearStart(year)
 
	date2=yearStart(year+1)
 
@@ -131,11 +131,26 @@ def populationAge(year,country):
 
			)
 
			group by playing_years
 
	"""
 
	return cursor.execute(query,(date2,date1,date2,country))
 

	
 
	res=cursor.execute(query,(date2,date1,date2,country))
 
	print("celé roky hraní\tpočet hráčů")
 
	for rec in res:
 
		print("\t".join([str(x) for x in rec]))
 

	
 
def populationAge(year1,year2,country):
 
	res=dict()
 

	
 
	for year in range(year1,year2):
 
		records=_populationAge(year,country)
 
		for (age,playerCount) in records:
 
			if age not in res:
 
				res[age]=dict()
 
			res[age][year]=playerCount
 
		print("\r",year,end="",file=sys.stderr)
 
	print("\r",end="",file=sys.stderr)
 

	
 
	print("Počty aktivních hráčů v {0} hrajících tolik a více let".format(country))
 
	print("roky hraní\t"+"\t".join(str(y) for y in range(year1,year2)))
 
	for age in sorted(res.keys()):
 
		print(age,end="\t")
 
		print("\t".join(str(res[age].get(y,0)) for y in range(year1,year2)))
 

	
 

	
 
def tournamentAttendance(year):
 
@@ -151,10 +166,8 @@ def tournamentAttendance(year):
 

	
 

	
 
# playerYear("Kotowski Jaroslav",2017)
 
# yearByCountry(2017)
 
# timeRank(2017,"CZ")
 
# populationStrength(2017,"CZ")
 
# populationAge(2006,"CZ")
 
# tournamentAttendance(2010)
 
# yearsByCountry(2001,2018)
 
# populationStrength(2017,2018,"CZ")
 
# populationStrength(2001,2018,"RU")
 
# populationAge(2001,2018,"RU")
0 comments (0 inline, 0 general)