Changeset - 051ee2d1dbdd
[Not reviewed]
default
0 1 0
Laman - 7 years ago 2018-04-01 14:33:26

tournamentAttendance rozšířena na rozsah let
1 file changed with 21 insertions and 6 deletions:
0 comments (0 inline, 0 general)
queries.py
Show inline comments
 
@@ -153,21 +153,36 @@ def populationAge(year1,year2,country):
 
		print("\t".join(str(res[age].get(y,0)) for y in range(year1,year2)))
 

	
 

	
 
def tournamentAttendance(year):
 
def _tournamentAttendance(year):
 
	"""Návštěvnosti turnajů za daný rok, dělené podle země konání."""
 
	date1=yearStart(year)
 
	date2=yearStart(year+1)
 
	query="""select country_code,sum(player_count) from tournaments where datum>=date(?) and datum<date(?) group by country_code"""
 

	
 
	res=cursor.execute(query,(date1,date2))
 
	print("kód země\tpočet hráčů na turnajích")
 
	for rec in res:
 
		print("\t".join([str(x) for x in rec]))
 
	return cursor.execute(query,(date1,date2))
 

	
 

	
 
def tournamentAttendance(year1,year2):
 
	res=dict()
 

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

	
 
	print("Návštěvnosti (počty hráčů) na turnajích podle let")
 
	print("kód země\t"+"\t".join(str(y) for y in range(year1,year2)))
 
	for country in sorted(res.keys()):
 
		print(country,end="\t")
 
		print("\t".join(str(res[country].get(y,0)) for y in range(year1,year2)))
 

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