Changeset - bc762fdfee0f
[Not reviewed]
default
0 3 0
Laman - 7 years ago 2018-03-27 16:57:49

dokumentace, komentáře
3 files changed with 16 insertions and 0 deletions:
0 comments (0 inline, 0 general)
egd.py
Show inline comments
 
@@ -61,6 +61,7 @@ def setupDB():
 
	cursor.execute("""create table tournaments (code text primary key, datum text, class text, round_count integer, player_count integer, country_code text, description text)""")
 
	cursor.execute("""create table players (pin integer primary key, name text)""")
 
	cursor.execute("""create table players_performance (pin integer references players(pin), tournament_code text references tournaments(code), country_code text, club text, win_count integer, game_count integer, rating_before real, rating_after real, primary key (pin,tournament_code))""")
 

	
 
	cursor.execute("""
 
		create view players_performance_tournaments (pin,p_country_code,rating_before,rating_after,t_country_code,datum) as
 
			select pin,pp.country_code,rating_before,rating_after,ts.country_code,datum
queries.py
Show inline comments
 
@@ -9,6 +9,7 @@ def yearStart(year):
 

	
 

	
 
def playerYear(name,year):
 
	"""Výsledky hráče s daným jménem pro daný rok."""
 
	query="""
 
		select name, datum, win_count, game_count, rating_after, rating_after-rating_before
 
			from players natural join players_performance as pp join tournaments as ts on pp.tournament_code=ts.code
 
@@ -25,6 +26,7 @@ def playerYear(name,year):
 

	
 

	
 
def yearByCountry(year):
 
	"""Počty hráčů s turnajem odehraným v daném roce, dělené podle země původu."""
 
	date1=yearStart(year)
 
	date2=yearStart(year+1)
 
	query="""
 
@@ -44,6 +46,7 @@ def yearByCountry(year):
 

	
 

	
 
def timeRank(year,country):
 
	"""Výpis hráčů dané země aktivních v daném roce."""
 
	date1=yearStart(year)
 
	date2=yearStart(year+1)
 
	query="""
 
@@ -60,6 +63,7 @@ def timeRank(year,country):
 

	
 

	
 
def populationStrength(year,country):
 
	"""Rozdělení populace země v daném roce podle ratingu (po stovkách). Uvažují se pouze aktivní hráči."""
 
	date1=yearStart(year)
 
	date2=yearStart(year+1)
 
	query="""
 
@@ -77,6 +81,7 @@ def populationStrength(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)
 
	query="""
 
@@ -97,6 +102,7 @@ def populationAge(year,country):
 

	
 

	
 
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"""
readme.md
Show inline comments
 
@@ -33,3 +33,12 @@ Co se vztahuje zároveň k hráči a k turnaji. Většina položek all.hst.
 
* (integer) game_count
 
* (real) rating_before
 
* (real) rating_after
 

	
 
### players_performance_tournaments
 
Pohled na tournaments a players_performance.
 
* (integer) pin
 
* (text) p_country_code - země hráče
 
* (real) rating_before
 
* (real) rating_after
 
* (text) t_country_code - lokace turnaje
 
* (text) datum
0 comments (0 inline, 0 general)