Skip to content

Commit

Permalink
Fix issues with types on datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennanB committed Sep 24, 2024
1 parent 3750f7e commit 80a217e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 43 deletions.
42 changes: 2 additions & 40 deletions matches.csv
Original file line number Diff line number Diff line change
@@ -1,40 +1,2 @@
Matthew422,Darre,Casey422,AdamD,Brennan4476,Alex1629,196,139
Matthew422,Darre,AdamD,Casey422,Brennan4476,Alex1629,186,134
Matthew422,Darre,Brennan4476,Casey422,AdamD,Alex1629,186,148
Matthew422,Darre,Alex1629,Casey422,AdamD,Brennan4476,150,161
Matthew422,Casey422,AdamD,Darre,Brennan4476,Alex1629,152,130
Matthew422,Casey422,Brennan4476,Darre,AdamD,Alex1629,127,115
Matthew422,Casey422,Alex1629,Darre,AdamD,Brennan4476,139,136
Matthew422,AdamD,Brennan4476,Darre,Casey422,Alex1629,123,148
Matthew422,AdamD,Alex1629,Darre,Casey422,Brennan4476,144,122
Matthew422,Brennan4476,Alex1629,Darre,Casey422,AdamD,137,135
Charlemagne,Eitan,Noahplwg,Andrew,Liam5690,Parin,166,152
Charlemagne,Eitan,Andrew,Noahplwg,Liam5690,Parin,150,155
Charlemagne,Eitan,Liam5690,Noahplwg,Andrew,Parin,164,143
Charlemagne,Eitan,Parin,Noahplwg,Andrew,Liam5690,182,169
Charlemagne,Noahplwg,Andrew,Eitan,Liam5690,Parin,168,164
Charlemagne,Noahplwg,Liam5690,Eitan,Andrew,Parin,143,157
Charlemagne,Noahplwg,Parin,Eitan,Andrew,Liam5690,168,162
Charlemagne,Andrew,Liam5690,Eitan,Noahplwg,Parin,168,161
Charlemagne,Andrew,Parin,Eitan,Noahplwg,Liam5690,141,157
Charlemagne,Liam5690,Parin,Eitan,Noahplwg,Andrew,187,155
Crayfish,waxton,Roma,Evan8738,Logan4476,Dak346,185,150
Crayfish,waxton,Evan8738,Roma,Logan4476,Dak346,152,152
Crayfish,waxton,Logan4476,Roma,Evan8738,Dak346,186,152
Crayfish,waxton,Dak346,Roma,Evan8738,Logan4476,152,178
Crayfish,Roma,Evan8738,waxton,Logan4476,Dak346,150,148
Crayfish,Roma,Logan4476,waxton,Evan8738,Dak346,168,113
Crayfish,Roma,Dak346,waxton,Evan8738,Logan4476,162,129
Crayfish,Evan8738,Logan4476,waxton,Roma,Dak346,145,120
Crayfish,Evan8738,Dak346,waxton,Roma,Logan4476,141,182
Crayfish,Logan4476,Dak346,waxton,Roma,Evan8738,163,143
stel,C4678,Jeff2718,Ambrose8156,thebirchtrees,Kaiju_Jones,179,160
stel,C4678,Ambrose8156,Jeff2718,thebirchtrees,Kaiju_Jones,178,107
stel,C4678,thebirchtrees,Jeff2718,Ambrose8156,Kaiju_Jones,161,149
stel,C4678,Kaiju_Jones,Jeff2718,Ambrose8156,thebirchtrees,174,130
stel,Jeff2718,Ambrose8156,C4678,thebirchtrees,Kaiju_Jones,167,151
stel,Jeff2718,thebirchtrees,C4678,Ambrose8156,Kaiju_Jones,172,167
stel,Jeff2718,Kaiju_Jones,C4678,Ambrose8156,thebirchtrees,144,136
stel,Ambrose8156,thebirchtrees,C4678,Jeff2718,Kaiju_Jones,161,134
stel,Ambrose8156,Kaiju_Jones,C4678,Jeff2718,thebirchtrees,161,157
stel,thebirchtrees,Kaiju_Jones,C4678,Jeff2718,Ambrose8156,137,136
eback0,Noah,Parin,Logan4476,Brennan4476,Jack,0,166
eback0,Noah,Parin,Logan4476,Brennan4476,Jack,138,144
15 changes: 12 additions & 3 deletions ranked/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,23 @@ def player_info(request, name, player_id):
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/ranked'))

player_info = PlayerElo.objects.filter(
game_mode__short_code=name, player__id=player_id)
game_mode__short_code=name, player__id=player_id
)

if not player_info.exists():
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/ranked'))

player = player_info[0]
player = player_info.first()

# Handle cases where last_match_played_time is None
if player.last_match_played_time:
delta_hours = (timezone.now() - player.last_match_played_time).total_seconds() / 3600
else:
# Define a default value or handle as needed
# For example, setting delta_hours to 0 or a specific number
delta_hours = 0 # Or set to a default like 24 * 7 for a week

mmr = round(mmr_calc(player.elo, player.matches_played, (datetime.now(timezone.utc) - player.last_match_played_time).total_seconds()/3600), 1)
mmr = round(mmr_calc(player.elo, player.matches_played, delta_hours), 1)

elo_history = EloHistory.objects.filter(player_elo=player)
match_labels = [eh.match_number for eh in elo_history]
Expand Down

0 comments on commit 80a217e

Please sign in to comment.