-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge in changes from aircraft stats mod.
- Loading branch information
Showing
11 changed files
with
148 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/mod_stats_by_aircraft/background_jobs/fix_no_deaths_player_kb.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from .background_job import BackgroundJob | ||
from stats.models import Sortie | ||
from ..aircraft_mod_models import AircraftBucket, AircraftKillboard | ||
|
||
|
||
class FixNoDeathsPlayerKB(BackgroundJob): | ||
""" | ||
A bug in the early versions of 1.2.X the retroactive compute to not count player deaths in aircraft overview | ||
killboards. | ||
This job resets the loses, and recomputes them. Not that the reset is necessary, since the normal, not retroactive | ||
compute does not have this issue. | ||
""" | ||
|
||
def reset_relevant_fields(self, tour_cutoff): | ||
AircraftKillboard.objects.filter( | ||
aircraft_1__player__isnull=False, | ||
reset_player_loses=False, | ||
tour__id__gte=tour_cutoff | ||
).update( | ||
aircraft_2_kills=0, | ||
aircraft_2_shotdown=0, | ||
aircraft_2_assists=0, | ||
aircraft_2_pk_assists=0, | ||
aircraft_2_distinct_hits=0, | ||
reset_player_loses=True | ||
) | ||
|
||
AircraftKillboard.objects.filter( | ||
aircraft_2__player__isnull=False, | ||
reset_player_loses=False, | ||
tour__id__gte=tour_cutoff | ||
).update( | ||
aircraft_1_kills=0, | ||
aircraft_1_shotdown=0, | ||
aircraft_1_assists=0, | ||
aircraft_1_pk_assists=0, | ||
aircraft_1_distinct_hits=0, | ||
reset_player_loses=True | ||
) | ||
|
||
def query_find_sorties(self, tour_cutoff): | ||
return (Sortie.objects.filter(SortieAugmentation_MOD_STATS_BY_AIRCRAFT__added_player_kb_losses=False, | ||
aircraft__cls_base='aircraft', tour__id__gte=tour_cutoff) | ||
.order_by('-tour__id')) | ||
|
||
def compute_for_sortie(self, sortie): | ||
from ..stats_whore import process_log_entries, get_sortie_type | ||
|
||
buckets = [(AircraftBucket.objects.get_or_create(tour=sortie.tour, aircraft=sortie.aircraft, | ||
filter_type='NO_FILTER', player=None))[0]] | ||
filter_type = get_sortie_type(sortie) | ||
has_subtype = filter_type != 'NO_FILTER' | ||
if has_subtype: | ||
buckets.append((AircraftBucket.objects.get_or_create(tour=sortie.tour, aircraft=sortie.aircraft, | ||
filter_type=filter_type, player=None))[0]) | ||
|
||
for bucket in buckets: | ||
process_log_entries(bucket, sortie, has_subtype, bucket.filter_type != 'NO_FILTER', | ||
compute_only_pure_killboard_stats=True, stop_update_primary_bucket=True) | ||
|
||
sortie.SortieAugmentation_MOD_STATS_BY_AIRCRAFT.added_player_kb_losses = True | ||
sortie.SortieAugmentation_MOD_STATS_BY_AIRCRAFT.save() | ||
|
||
def log_update(self, to_compute): | ||
return '[mod_stats_by_aircraft]: Adding loses in player aircraft killboards {} sorties left to process.' \ | ||
.format(to_compute) | ||
|
||
def log_done(self): | ||
return '[mod_stats_by_aircraft]: Completed adding loses in player aircraft killboards.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/mod_stats_by_aircraft/migrations/0005_fix_player_killboards_losses.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.29 on 2021-05-06 18:55 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('mod_stats_by_aircraft', '0004_fix_killboard_stats'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='aircraftkillboard', | ||
name='reset_player_loses', | ||
field=models.BooleanField(db_index=True, default=False), | ||
), | ||
migrations.AddField( | ||
model_name='sortieaugmentation', | ||
name='added_player_kb_losses', | ||
field=models.BooleanField(db_index=True, default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters