Skip to content

Commit

Permalink
Fix for SQL Query
Browse files Browse the repository at this point in the history
  • Loading branch information
aristocat85 committed Nov 7, 2020
1 parent 23a2409 commit 5a961a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion DSTBundesliga/apps/leagues/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def player_stats(request, position=None):
if position:
pos_filter = "where position = '{position}'".format(position=position)

players = players.raw("select * from (select id, first_name, last_name, position, points, games_played, points/games_played as avg_points from leagues_player as whatever left join (select player_id, sum(points) as points, Sum(Case when stats = '""' then 0 when stats='{}' then 0 else 1 end) as games_played from leagues_statsweek group by player_id) on id=player_id %s) as player_data left join (select player_id, AVG(pick_no) as adp from leagues_pick group by player_id) as adp_picks on id=player_id order by points desc, adp asc;" % pos_filter)
players = players.raw("select * from (select id, first_name, last_name, position, points, games_played, points/games_played as avg_points from leagues_player as whatever left join (select player_id, sum(points) as points, Sum(Case when stats = '""' then 0 when stats='{}' then 0 else 1 end) as games_played from leagues_statsweek group by player_id) as asdf on id=player_id %s) as player_data left join (select player_id, AVG(pick_no) as adp from leagues_pick group by player_id) as adp_picks on id=player_id order by points desc, adp asc;" % pos_filter)

player_stats = players[:200]

Expand Down

0 comments on commit 5a961a3

Please sign in to comment.