From fce452268af3368e7836d0a02d1966e4ba7eca77 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:10:35 -0600 Subject: [PATCH 01/17] Moving enforcing of teams back in. Attempting to play with cvars. --- get5/get5_test.py | 2 +- get5/match.py | 3 +++ get5/models.py | 8 ++++---- get5/server_test.py | 6 +++--- get5/templates/match_create.html | 7 +++++++ migrations/versions/254a3741efe3_.py | 21 +++++++++++++++++++++ 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 migrations/versions/254a3741efe3_.py diff --git a/get5/get5_test.py b/get5/get5_test.py index fc66d49..9cac259 100644 --- a/get5/get5_test.py +++ b/get5/get5_test.py @@ -47,7 +47,7 @@ def create_test_data(self): db.session.commit() Match.create(user, team1.id, team2.id, '', '', 1, False, - 'Map {MAPNUMBER}', ['de_dust2', 'de_cache', 'de_mirage'], season.id, 'always_knife', 'CT', server.id, 0, 0, None, False) + 'Map {MAPNUMBER}', ['de_dust2', 'de_cache', 'de_mirage'], season.id, 'always_knife', 'CT', server.id, 0, 0, None, False, False) db.session.commit() vetoBan = Veto.create(1, 'EnvyUs', 'de_dust2', 'ban') diff --git a/get5/match.py b/get5/match.py index 9edd5ff..723021f 100755 --- a/get5/match.py +++ b/get5/match.py @@ -133,6 +133,9 @@ class MatchForm(Form): private_match = BooleanField('Private Match?', default=False) + enforce_teams = BooleanField('Disable Check Auth', + default=True) + def add_teams(self, user): if self.team1_id.choices is None: self.team1_id.choices = [] diff --git a/get5/models.py b/get5/models.py index 7b0ad75..992773c 100755 --- a/get5/models.py +++ b/get5/models.py @@ -372,13 +372,13 @@ class Match(db.Model): team2_series_score = db.Column(db.Integer, default=0) spectator_auths = db.Column(db.PickleType) private_match = db.Column(db.Boolean) - + enforce_teams = db.Column(db.Boolean, default=True) @staticmethod def create(user, team1_id, team2_id, team1_string, team2_string, max_maps, skip_veto, title, veto_mappool, season_id, side_type, veto_first, server_id=None, team1_series_score=None, team2_series_score=None, - spectator_auths=None, private_match=False): + spectator_auths=None, private_match=False, enforce_teams=True): rv = Match() rv.user_id = user.id rv.team1_id = team1_id @@ -402,6 +402,7 @@ def create(user, team1_id, team2_id, team1_string, team2_string, rv.team2_series_score = team2_series_score rv.spectator_auths = spectator_auths rv.private_match = private_match + rv.enforce_teams = enforce_teams db.session.add(rv) return rv @@ -564,10 +565,9 @@ def add_if(key, value): add_team_data('team2', self.team2_id, self.team2_string) d['cvars'] = {} - d['cvars']['get5_web_api_url'] = url_for( 'home', _external=True, _scheme='http') - + d['cvars']['get5_check_auths'] = int(self.enforce_teams) # Add in for spectators modification. d['min_spectators_to_ready'] = 0 diff --git a/get5/server_test.py b/get5/server_test.py index 3d6b9a9..6f1cf2c 100755 --- a/get5/server_test.py +++ b/get5/server_test.py @@ -95,7 +95,7 @@ def test_server_deletion(self): sess['user_id'] = 1 response = c.get('/server/1/delete') self.assertEqual(response.status_code, 400) - self.assertIn('{"message":"Cannot delete server when in use."}\n', response.data) + self.assertIn('{\n "message": "Cannot delete server when in use."\n}\n', response.data) # Can't delete some else's server when logged in with self.app as c: @@ -103,13 +103,13 @@ def test_server_deletion(self): sess['user_id'] = 2 response = c.get('/server/2/delete') self.assertEqual(response.status_code, 400) - self.assertIn('{"message":"You do not have access to this server."}\n', response.data) + self.assertIn('{\n "message": "You do not have access to this server."\n}\n', response.data) # Can't delete some else's server without being logged in with self.app as c: response = c.get('/server/1/delete') self.assertEqual(response.status_code, 400) - self.assertIn('{"message":"You do not have access to this server."}\n', response.data) + self.assertIn('{\n "message": "You do not have access to this server."\n}\n', response.data) # Make sure a user can't edit someone else's servers def test_edit_server_wronguser(self): diff --git a/get5/templates/match_create.html b/get5/templates/match_create.html index 841e5c2..1c62fff 100644 --- a/get5/templates/match_create.html +++ b/get5/templates/match_create.html @@ -153,6 +153,13 @@ +
+ {{ form.enforce_teams.label(class="col-sm-2 control-label") }} +
+ {{ form.enforce_teams(class="form-control input-sm") }} +
+
+
{{ form.spectator_string.label(class="col-sm-2 control-label") }}
diff --git a/migrations/versions/254a3741efe3_.py b/migrations/versions/254a3741efe3_.py new file mode 100644 index 0000000..5bda844 --- /dev/null +++ b/migrations/versions/254a3741efe3_.py @@ -0,0 +1,21 @@ +"""Adding back in enforcement of teams. + +Revision ID: 254a3741efe3 +Revises: f5efc36b3cc9 +Create Date: 2019-08-28 21:59:22.176239 + +""" + +# revision identifiers, used by Alembic. +revision = '254a3741efe3' +down_revision = 'f5efc36b3cc9' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +def upgrade(): + op.add_column('match', sa.Column('enforce_teams', sa.Boolean(), nullable=True)) + +def downgrade(): + op.drop_column('match', 'enforce_teams') \ No newline at end of file From b784c96ff0a01d61fba7180a8b73fc174c2707fd Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:13:20 -0600 Subject: [PATCH 02/17] Broken tests locally bit Travis is OK. Ya sure. Dumb tests. --- get5/server_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/get5/server_test.py b/get5/server_test.py index 6f1cf2c..3d6b9a9 100755 --- a/get5/server_test.py +++ b/get5/server_test.py @@ -95,7 +95,7 @@ def test_server_deletion(self): sess['user_id'] = 1 response = c.get('/server/1/delete') self.assertEqual(response.status_code, 400) - self.assertIn('{\n "message": "Cannot delete server when in use."\n}\n', response.data) + self.assertIn('{"message":"Cannot delete server when in use."}\n', response.data) # Can't delete some else's server when logged in with self.app as c: @@ -103,13 +103,13 @@ def test_server_deletion(self): sess['user_id'] = 2 response = c.get('/server/2/delete') self.assertEqual(response.status_code, 400) - self.assertIn('{\n "message": "You do not have access to this server."\n}\n', response.data) + self.assertIn('{"message":"You do not have access to this server."}\n', response.data) # Can't delete some else's server without being logged in with self.app as c: response = c.get('/server/1/delete') self.assertEqual(response.status_code, 400) - self.assertIn('{\n "message": "You do not have access to this server."\n}\n', response.data) + self.assertIn('{"message":"You do not have access to this server."}\n', response.data) # Make sure a user can't edit someone else's servers def test_edit_server_wronguser(self): From 2935c34c1942a6c59b411bec2bda1823e7140c0c Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:19:13 -0600 Subject: [PATCH 03/17] Language change. --- get5/match.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get5/match.py b/get5/match.py index 723021f..88e20f8 100755 --- a/get5/match.py +++ b/get5/match.py @@ -133,7 +133,7 @@ class MatchForm(Form): private_match = BooleanField('Private Match?', default=False) - enforce_teams = BooleanField('Disable Check Auth', + enforce_teams = BooleanField('Enforce Auths on Team', default=True) def add_teams(self, user): From 38027f2684efdb18d2ef7c3d9e0ca54d7c928653 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:24:26 -0600 Subject: [PATCH 04/17] Update to enforce auth to 0. --- get5/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/get5/models.py b/get5/models.py index 992773c..00d4096 100755 --- a/get5/models.py +++ b/get5/models.py @@ -566,8 +566,8 @@ def add_if(key, value): d['cvars'] = {} d['cvars']['get5_web_api_url'] = url_for( - 'home', _external=True, _scheme='http') - d['cvars']['get5_check_auths'] = int(self.enforce_teams) + 'home', _external=True, _scheme='http') + d['cvars']['get5_check_auths'] = int(self.enforce_teams) if self.enforce_teams is not None else 0 # Add in for spectators modification. d['min_spectators_to_ready'] = 0 From 371ebde9fc47faa01f9d301492eedb0a98085912 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:26:17 -0600 Subject: [PATCH 05/17] use string. --- get5/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get5/models.py b/get5/models.py index 00d4096..2178b59 100755 --- a/get5/models.py +++ b/get5/models.py @@ -567,7 +567,7 @@ def add_if(key, value): d['cvars'] = {} d['cvars']['get5_web_api_url'] = url_for( 'home', _external=True, _scheme='http') - d['cvars']['get5_check_auths'] = int(self.enforce_teams) if self.enforce_teams is not None else 0 + d['cvars']['get5_check_auths'] = str(self.enforce_teams) if self.enforce_teams is not None else "0" # Add in for spectators modification. d['min_spectators_to_ready'] = 0 From 24facc818af94cc75e83d9ca1f50a81a545b1987 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:28:47 -0600 Subject: [PATCH 06/17] Wow. Missed checking boolean. --- get5/match.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get5/match.py b/get5/match.py index 88e20f8..318cb19 100755 --- a/get5/match.py +++ b/get5/match.py @@ -265,7 +265,7 @@ def match_create(): season_id, form.data['side_type'], form.data['veto_first'], form.data['server_id'], team1_series_score, team2_series_score, specList, - form.data['private_match']) + form.data['private_match'], form.data['enforce_auths']) # Save plugin version data if we have it if json_reply and 'plugin_version' in json_reply: From 3afff93231b3215c6e5127ca29129d845951e2a3 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:31:22 -0600 Subject: [PATCH 07/17] typo. --- get5/match.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get5/match.py b/get5/match.py index 318cb19..87b6ea5 100755 --- a/get5/match.py +++ b/get5/match.py @@ -265,7 +265,7 @@ def match_create(): season_id, form.data['side_type'], form.data['veto_first'], form.data['server_id'], team1_series_score, team2_series_score, specList, - form.data['private_match'], form.data['enforce_auths']) + form.data['private_match'], form.data['enforce_teams']) # Save plugin version data if we have it if json_reply and 'plugin_version' in json_reply: From 148b721f7d6a1aea76a14f50b89d15bc1d09dfb3 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:32:55 -0600 Subject: [PATCH 08/17] Late night coding = bad. Stop doing it. --- get5/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get5/models.py b/get5/models.py index 2178b59..1829001 100755 --- a/get5/models.py +++ b/get5/models.py @@ -567,7 +567,7 @@ def add_if(key, value): d['cvars'] = {} d['cvars']['get5_web_api_url'] = url_for( 'home', _external=True, _scheme='http') - d['cvars']['get5_check_auths'] = str(self.enforce_teams) if self.enforce_teams is not None else "0" + d['cvars']['get5_check_auths'] = int(self.enforce_teams) # Add in for spectators modification. d['min_spectators_to_ready'] = 0 From 1f804aa0af740ef5ebfb99424dad63d6b32f6488 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:35:39 -0600 Subject: [PATCH 09/17] More model fixes. Only doing this to get dev machine running. --- get5/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/get5/models.py b/get5/models.py index 1829001..ac81de0 100755 --- a/get5/models.py +++ b/get5/models.py @@ -567,9 +567,9 @@ def add_if(key, value): d['cvars'] = {} d['cvars']['get5_web_api_url'] = url_for( 'home', _external=True, _scheme='http') - d['cvars']['get5_check_auths'] = int(self.enforce_teams) + d['cvars']['get5_check_auths'] = "1" if self.enforce_teams else "0" # Add in for spectators modification. - d['min_spectators_to_ready'] = 0 + d['min_spectators_to_ready'] = "0" # Perm spectators will go within config, then can add more from match # screen. From 24e6fa20e0ae74d649bd488d88a1ddf6c17274f0 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 28 Aug 2019 22:37:59 -0600 Subject: [PATCH 10/17] ????????????? Why is a string expected for auth check but spectators an int. --- get5/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get5/models.py b/get5/models.py index ac81de0..1f2c7d0 100755 --- a/get5/models.py +++ b/get5/models.py @@ -569,7 +569,7 @@ def add_if(key, value): 'home', _external=True, _scheme='http') d['cvars']['get5_check_auths'] = "1" if self.enforce_teams else "0" # Add in for spectators modification. - d['min_spectators_to_ready'] = "0" + d['min_spectators_to_ready'] = 0 # Perm spectators will go within config, then can add more from match # screen. From 3a5ceeb518558c9e74391c5580d0c2a7dc14ddbf Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 31 Aug 2019 16:49:59 -0600 Subject: [PATCH 11/17] Resolves #129 dates and seasons in main matches page. --- get5/match.py | 3 ++- get5/models.py | 21 +++++++++++++++++++++ get5/templates/matches.html | 18 ++++++++++++++++-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/get5/match.py b/get5/match.py index 87b6ea5..34f7bba 100755 --- a/get5/match.py +++ b/get5/match.py @@ -254,7 +254,8 @@ def match_create(): suc, new_auth = steamid.auth_to_steam64(auth) if suc: specList.append(new_auth) - + if not specList: + specList = None # End Spectator Feature match = Match.create( diff --git a/get5/models.py b/get5/models.py index 1f2c7d0..7133b15 100755 --- a/get5/models.py +++ b/get5/models.py @@ -317,6 +317,9 @@ def get_recent_matches(self, limit=10): else: return recent_matches + def get_url(self): + return url_for('season.seasons', seasonid=self.id) + def __repr__(self): return 'Season(id={}, user_id={}, name={}, start_date={}, end_date={})'.format( self.id, self.user_id, self.name, self.start_date, self.end_date) @@ -458,6 +461,21 @@ def live(self): def get_server(self): return GameServer.query.filter_by(id=self.server_id).first() + def get_start_time(self): + return self.start_time + + def get_end_time(self): + return self.end_time + + def get_season(self): + if self.season_id: + return Season.query.get(self.season_id) + else: + return None + + def get_season_id(self): + return self.season_id + def get_current_score(self): if self.max_maps == 1: mapstat = self.map_stats.first() @@ -583,6 +601,9 @@ def add_if(key, value): for spectator in self.spectator_auths: d['spectators']["players"].append(spectator) + if not d['spectators']['players']: + d['spectators'] = None + if self.veto_mappool: d['maplist'] = [] for map in self.veto_mappool.split(): diff --git a/get5/templates/matches.html b/get5/templates/matches.html index 28aadef..e34bbe0 100644 --- a/get5/templates/matches.html +++ b/get5/templates/matches.html @@ -24,12 +24,15 @@

Team 1 Team 2 Status + Start Time + End Time {% if my_matches %} Server {% else %} Owner {% endif %} + Season @@ -51,7 +54,14 @@

{{ match.get_status_string() }} - + {% if match.live() or match.finished() %} + + {{ match.get_start_time() }} + + + {{ match.get_end_time() }} + + {% endif %} {% if my_matches %} {% if match.get_server() is not none %} {{ match.get_server().get_display() }} {% endif %} @@ -62,7 +72,11 @@

{% else %} {{ match.get_user().name }} {% endif %} - + {% if match.get_season() %} + {{ match.get_season().name }} + {% else %} + N/A + {%endif%} {% endfor %} From a41e1d56d03d740a180405a3b4cf8babc176675b Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 31 Aug 2019 17:10:26 -0600 Subject: [PATCH 12/17] Resolve auth issue on player leaderboards. Include individual leaderboards in /seasons. Include null end dates for ongoing seasons. --- get5/leaderboard.py | 4 ++-- get5/match.py | 2 +- get5/templates/layout.html | 9 +++++++++ get5/templates/seasons.html | 8 ++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/get5/leaderboard.py b/get5/leaderboard.py index da1829a..6609cd3 100644 --- a/get5/leaderboard.py +++ b/get5/leaderboard.py @@ -134,10 +134,10 @@ def seasonal_leaderboard(seasonid): def seasonal_player_leaderboard(seasonid): season = Season.query.get_or_404(seasonid) playerValues = getPlayerLeaderboard(seasonid) - return render_template('statleaderboard.html', board=playerValues, season=season.name) + return render_template('statleaderboard.html', user=g.user, board=playerValues, season=season.name) @leaderboard_blueprint.route('/leaderboard/players') def player_leaderboard(): playerValues = getPlayerLeaderboard() - return render_template('statleaderboard.html', board=playerValues) + return render_template('statleaderboard.html', user=g.user, board=playerValues) diff --git a/get5/match.py b/get5/match.py index 34f7bba..76e71c7 100755 --- a/get5/match.py +++ b/get5/match.py @@ -180,7 +180,7 @@ def add_seasons(self): self.season_selection.choices = [] season_tuples = [] season_tuples.append((0, 'No Season')) - for seasons in Season.query.filter(Season.end_date >= datetime.now()).order_by(-Season.id): + for seasons in Season.query.filter((Season.end_date >= datetime.now()) | (Season.end_date.is_(None))).order_by(-Season.id): season_tuples.append((seasons.id, seasons.name)) self.season_selection.choices += season_tuples diff --git a/get5/templates/layout.html b/get5/templates/layout.html index 42f2b48..bd654e4 100644 --- a/get5/templates/layout.html +++ b/get5/templates/layout.html @@ -97,6 +97,15 @@ Create a Season

+
  • Logout
  • {% endif %} diff --git a/get5/templates/seasons.html b/get5/templates/seasons.html index c997802..243b193 100644 --- a/get5/templates/seasons.html +++ b/get5/templates/seasons.html @@ -20,7 +20,8 @@

    Season Name Start Date End Date - Leaderboard + Team Leaderboard + Individual Leaderboard @@ -40,9 +41,12 @@

    {% endif %} - Leaderboard + Team Leaderboard + + Indvidual Leaderboard + {% if season.can_edit(user) %} From f277920651e4c07afb585028203427ad622a8555 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 1 Sep 2019 11:58:11 -0600 Subject: [PATCH 13/17] Include hack fix to ensure check_auths works as intended. Updated Readme. --- README.md | 4 ++-- get5/models.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f702e5c..6e7310f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ -This is a web panel meant to be used in conjunction with the [get5](https://github.com/splewis/get5) CS:GO server plugin. It provides a more convenient way of managing matches and match servers. +This is a web panel meant to be used in conjunction with the [get5](https://github.com/splewis/get5) CS:GO server plugin. It provides a more convenient way of managing matches and match servers. **This webpanel is intended for competitive 5v5 leagues and scrims, and nothing more.** This fork of get5 introduces a few new features that are used within get5 already, but were not originally ported over to the experimental web-panel. I've tried to make the web panel a little bit more secure (storing passwords, etc), and more handy for people to organize matches (Seasons and Leaderboards). Right now it's considered complete as it fits my needs and small-scale application. If you have any feature suggestions, *please create an issue*. It's extremely unlikely I'll put any more work into it, but pull requests are always welcome with features, provided they've been tested and pass CI! @@ -29,7 +29,7 @@ Once you do this, the site will send an rcon command to the game server `get5_lo As the match owner, you will be able to cancel the match. Additionally, on its matchpage there is a dropdown to run admin commands: add players to the teams if a ringer is needed, pause the match, load a match backup, list match backups, and run any rcon command. -Note: when using this web panel, the CS:GO game servers **must** be have both the core get5 plugin and the get5_apistats plugin. This means the server must also be running the [Steamworks](https://forums.alliedmods.net/showthread.php?t=229556) and [SMJansson](https://forums.alliedmods.net/showthread.php?t=184604) extensions, as well as [System2](https://github.com/dordnung/System2/releases) (for automated demo uploads, if you so choose). If you are using the public webpanel, please do not do FTP uploads, as they will not link properly on the web-panel. +Note: when using this web panel, the CS:GO game servers **must** be have both the core get5 plugin and the get5_apistats plugin. This means the server must also be running the [Steamworks](https://forums.alliedmods.net/showthread.php?t=229556) and [SMJansson](https://forums.alliedmods.net/showthread.php?t=184604) extensions, as well as [System2](https://github.com/dordnung/System2/releases) (for automated demo uploads, if you so choose). If you are using the public webpanel, please do not do FTP uploads, as they will not link properly on the web-panel itself, but will still upload to your personal FTP server. ## Screenshots diff --git a/get5/models.py b/get5/models.py index 7133b15..490a5e8 100755 --- a/get5/models.py +++ b/get5/models.py @@ -505,6 +505,9 @@ def send_to_server(self): server.send_rcon_command( 'get5_web_api_key ' + self.api_key) + # ***HACK FIX TO ENSURE CHECK_AUTHS WORKS AS INTENDED*** + server.send_rcon_command('map de_dust2') + if loadmatch_response: # There should be no response return False From e671e65e6cdf07158a2eaa2bd42f8d558daac300 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 1 Sep 2019 12:59:51 -0600 Subject: [PATCH 14/17] Resolves #132: Include total matches in seasons URL. This may have performance impact on larger systems as it queries all matches with a season ID. --- get5/season.py | 3 ++- get5/templates/seasons.html | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/get5/season.py b/get5/season.py index 14747d0..e4e6847 100755 --- a/get5/season.py +++ b/get5/season.py @@ -43,8 +43,9 @@ class SeasonForm(Form): @season_blueprint.route('/seasons') def seasons(): seasons = Season.query.order_by(-Season.id) + seasoned_matches = Match.query.filter(Match.season_id.isnot(None), Match.cancelled==False) return render_template('seasons.html', user=g.user, seasons=seasons, - my_seasons=False, all_seasons=True) + my_seasons=False, matches=seasoned_matches, all_seasons=True) @season_blueprint.route('/season/create', methods=['GET', 'POST']) diff --git a/get5/templates/seasons.html b/get5/templates/seasons.html index 243b193..6b9e5fd 100644 --- a/get5/templates/seasons.html +++ b/get5/templates/seasons.html @@ -1,5 +1,4 @@ {% extends "layout.html" %} - {% block content %}
    @@ -20,6 +19,7 @@

    Season Name Start Date End Date + Total Matches Team Leaderboard Individual Leaderboard @@ -40,6 +40,10 @@

    {{ season.end_date.strftime('%Y-%m-%d') }} {% endif %} + + + {{ matches | selectattr('season_id', 'equalto', season.id) | map(attribute='season_id') | list | length }} + Team Leaderboard From a992725e6cface77c15c909d6120da111bba2f55 Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 2 Sep 2019 19:24:12 -0600 Subject: [PATCH 15/17] Resolves bug #134. --- get5/models.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/get5/models.py b/get5/models.py index 490a5e8..f54d5d3 100755 --- a/get5/models.py +++ b/get5/models.py @@ -699,20 +699,22 @@ def get_player_name(self): return get_steam_name(self.steam_id) def get_rating(self): - AverageKPR = 0.679 - AverageSPR = 0.317 - AverageRMK = 1.277 - KillRating = float(self.kills) / float(self.roundsplayed) / AverageKPR - SurvivalRating = float(self.roundsplayed - - self.deaths) / self.roundsplayed / AverageSPR - killcount = float(self.k1 + 4 * self.k2 + 9 * - self.k3 + 16 * self.k4 + 25 * self.k5) - RoundsWithMultipleKillsRating = killcount / \ - self.roundsplayed / AverageRMK - rating = (KillRating + 0.7 * SurvivalRating + - RoundsWithMultipleKillsRating) / 2.7 - return rating - + try: + AverageKPR = 0.679 + AverageSPR = 0.317 + AverageRMK = 1.277 + KillRating = float(self.kills) / float(self.roundsplayed) / AverageKPR + SurvivalRating = float(self.roundsplayed - + self.deaths) / self.roundsplayed / AverageSPR + killcount = float(self.k1 + 4 * self.k2 + 9 * + self.k3 + 16 * self.k4 + 25 * self.k5) + RoundsWithMultipleKillsRating = killcount / \ + self.roundsplayed / AverageRMK + rating = (KillRating + 0.7 * SurvivalRating + + RoundsWithMultipleKillsRating) / 2.7 + return rating + except ZeroDivisionError: + return 0 def get_kdr(self): if self.deaths == 0: return float(self.kills) From 58dd0c8d204fee94fdf478d628d047e5da7c83a9 Mon Sep 17 00:00:00 2001 From: PhlexPlexico <3514085+PhlexPlexico@users.noreply.github.com> Date: Tue, 3 Sep 2019 12:02:26 -0600 Subject: [PATCH 16/17] Remove cancelled matches from individual leaderboard query. --- get5/leaderboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/get5/leaderboard.py b/get5/leaderboard.py index 6609cd3..6f905cf 100644 --- a/get5/leaderboard.py +++ b/get5/leaderboard.py @@ -78,7 +78,8 @@ def getPlayerLeaderboard(seasonid=None): lstAllPlayerDict = [] playerValues = PlayerStats.query.all() matchQuery = Match.query.filter( - Match.season_id == seasonid).with_entities(Match.id) + Match.season_id == seasonid, + Match.cancelled == False).with_entities(Match.id) res = [int(r[0]) for r in matchQuery] # Filter through every steam ID for player in playerValues: From a992985d0e415d13f28b3051ba6e9473aa65c9b2 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 5 Sep 2019 20:51:13 -0600 Subject: [PATCH 17/17] Resolves #136. --- get5/match.py | 1 - get5/models.py | 2 +- get5/season.py | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/get5/match.py b/get5/match.py index 76e71c7..a7c59ac 100755 --- a/get5/match.py +++ b/get5/match.py @@ -404,7 +404,6 @@ def merge(a, b): matches = OrderedDict() match_num = 0 sorted_player_dict = OrderedDict() - app.logger.info('{}'.format(map_stat_list)) for map_stats in map_stat_list: for player in map_stats.player_stats: player_dict = merge( diff --git a/get5/models.py b/get5/models.py index f54d5d3..da95866 100755 --- a/get5/models.py +++ b/get5/models.py @@ -284,7 +284,7 @@ def get_season_name(self): return self.name def set_data(self, user, name, start_date, end_date): - self.user_id = user.id + self.user_id = self.user_id self.name = name self.start_date = start_date self.end_date = end_date diff --git a/get5/season.py b/get5/season.py index e4e6847..413db3d 100755 --- a/get5/season.py +++ b/get5/season.py @@ -95,7 +95,6 @@ def seasons_user(userid): user = User.query.get_or_404(userid) seasons = user.seasons.order_by(-Season.id) is_owner = (g.user is not None) and (userid == g.user.id) - app.logger.info('User is {}'.format(g.user)) return render_template('seasons.html', user=g.user, seasons=seasons, my_seasons=is_owner, all_matches=False, season_owner=user)