Skip to content

Commit

Permalink
Merge pull request #223 from Avasam/develop
Browse files Browse the repository at this point in the history
2021-06-02 Develop to main
  • Loading branch information
Avasam authored Jun 3, 2021
2 parents 60d4cf4 + 486fa6a commit c683522
Show file tree
Hide file tree
Showing 108 changed files with 1,803 additions and 19,666 deletions.
38 changes: 29 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
"plugin:switch-case/recommended",
"plugin:unicorn/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"project": "./tsconfig.json"
}
},
"settings": {
"react": {
Expand All @@ -44,10 +42,8 @@
"overrides": [
{
"files": [
"*.config.js",
"*-test.js",
"*.js",
"*.test.tsx",
"*.spec.js",
"environment.*",
"*.d.ts"
],
Expand Down Expand Up @@ -104,7 +100,7 @@
"unicorn/no-keyword-prefix": [
"error",
{
"blacklist": [
"disallowedPrefixes": [
"class",
"for",
"of"
Expand All @@ -123,14 +119,15 @@
],
"unicorn/numeric-separators-style": "error",
"unicorn/prefer-add-event-listener": "error",
"unicorn/prefer-object-has-own": "error",
"unicorn/prefer-query-selector": 0,
"unicorn/prefer-text-content": "error",
"unicorn/prevent-abbreviations": [
"error",
{
"checkDefaultAndNamespaceImports": false,
"checkShorthandImports": false,
"whitelist": {
"allowList": {
"fn": true,
"args": true,
// environment config
Expand Down Expand Up @@ -180,7 +177,8 @@
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "only-multiline"
"functions": "only-multiline",
"enums": "always-multiline"
}
],
"@typescript-eslint/consistent-type-definitions": [
Expand Down Expand Up @@ -252,6 +250,12 @@
}
],
"@typescript-eslint/no-type-alias": "off",
// Note: These 2 drown TS2304 and actually make the errors harder to understand.
// See: https://github.com/typescript-eslint/typescript-eslint/issues/2665
// There's nothing we can do until a pedantic any check in TypeScript is added
// Eg.: https://github.com/microsoft/TypeScript/issues/40174
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down Expand Up @@ -353,6 +357,7 @@
// Comparison
"a",
"b",
"x",
// Date formats
"dd",
"mm",
Expand All @@ -372,6 +377,15 @@
"error",
"prefer-single"
],
"max-len": [
"error",
{
"code": 120,
"tabWidth": 2,
"ignoreComments": false,
"ignorePattern": "^import .*?$"
}
],
// These rule does not correctly treat react's function components. See https://github.com/SonarSource/SonarJS/issues/2238
// Max very high as most of the react code lives in functions.
"max-lines": [
Expand Down Expand Up @@ -406,6 +420,12 @@
"no-dupe-else-if": "error",
"no-inner-declarations": "error",
"no-lonely-if": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"no-unneeded-ternary": "error",
"no-warning-comments": [
"warn",
Expand Down
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
"recommendations": [
"dbaeumer.vscode-eslint",
"ms-vscode.vscode-typescript-next",
"ms-pyright.pyright",
"ms-python.vscode-pylance",
"ms-python.python",
"sonarsource.sonarlint-vscode",
"davidanson.vscode-markdownlint",
"eamodio.gitlens",
"meganrogge.template-string-converter",
"shardulm94.trailing-spaces",
"hookyqr.minify"
],
"unwantedRecommendations": [
"ms-pyright.pyright",
"esbenp.prettier-vscode"
]
}
37 changes: 32 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"[python]": {
"editor.tabSize": 4,
},
"[py]": {
"editor.tabSize": 4,
},
"editor.formatOnSave": true,
// For node_modules
"[javascript]": {
"editor.formatOnSave": false,
},
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"html.format.wrapAttributes": "force-expand-multiline",
Expand All @@ -30,7 +31,7 @@
"source.fixAll.markdownlint": true
},
"python.linting.pylintEnabled": false,
"//": "Using flake8 as other linters are incomplete or have false positives with Requests",
// "Using flake8 as other linters are incomplete or have false positives with Requests",
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.linting.pycodestyleEnabled": false,
Expand All @@ -53,6 +54,32 @@
"mode": "auto"
}
],
// Copy those over to your user settings
"sonarlint.rules": {
"python:S1192": {
"level": "off"
},
"python:S3776": {
"level": "off"
},
"python:S107": {
"level": "off"
},
"typescript:S3735": {
"level": "off"
},
"typescript:S3358": {
"level": "off"
},
"typescript:S3776": {
"level": "off"
}
},
"files.insertFinalNewline": true,
"python.pythonPath": "",
"trailing-spaces.deleteModifiedLinesOnly": true,
"trailing-spaces.includeEmptyLines": true,
"trailing-spaces.trimOnSave": true,
"trailing-spaces.syntaxIgnore": [
"markdown"
],
}
2 changes: 1 addition & 1 deletion Changescripts/2020-04-10-Added-country-code.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE `player`
ALTER TABLE `player`
ADD COLUMN `country_code` VARCHAR(6) NULL AFTER `name`;
2 changes: 1 addition & 1 deletion Changescripts/2020-05-11-Fixed-country-code-too-small.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE `player`
ALTER TABLE `player`
MODIFY COLUMN `country_code` VARCHAR(6) NULL;
2 changes: 1 addition & 1 deletion Changescripts/2020-05-12-Added-score-details.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE `player`
ALTER TABLE `player`
ADD COLUMN `score_details` LONGTEXT NULL AFTER `score`;
2 changes: 1 addition & 1 deletion Changescripts/2021-01-03-Added-deadline-to-schedule.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE `schedule`
ALTER TABLE `schedule`
ADD COLUMN `deadline` DATETIME NULL AFTER `is_active`;
2 changes: 1 addition & 1 deletion Changescripts/2021-03-25-Nullable-deadlines.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE `schedule`
ALTER TABLE `schedule`
CHANGE COLUMN `deadline` `deadline` DATETIME NULL ;
3 changes: 3 additions & 0 deletions Changescripts/2021-06-01-Added_Region_Code_support.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- The biggest region code I found so far was "us/co/coloradosprings" at 21
ALTER TABLE `player`
CHANGE COLUMN `country_code` `country_code` VARCHAR(24) NULL DEFAULT NULL;
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# speedrun.com global scoreboard Webapp

The webapp version of an unofficial speedrun.com global scoreboard for competitive speedrunning
[![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)

Expand Down Expand Up @@ -52,10 +53,10 @@ Note: The soft cutoff works great on games such as Barney. But is too punishing

## Dev environment setup

Get yourself a [MySQL server](https://dev.mysql.com/downloads/mysql/) (PythonAnywhere uses version 5.6.40)
Install [Python](https://www.python.org/downloads/) 3.7+
Get yourself a [MySQL server](https://dev.mysql.com/downloads/mysql/) (as of 2021/06/01, PythonAnywhere uses version 5.7.27)
Install [Python](https://www.python.org/downloads/) 3.7 or 3.8 (but not 3.9 !)
Install PIP (this should come bundled with python 3.4+)
Run this command through the python interpreter (or prepend with `py -m` in a terminal): `pip install flask flask_cors flask_sqlalchemy sqlalchemy httplib2 simplejson mysql-connector requests pyjwt`
Run this command in a terminal: `pip3 install flask flask_cors flask_sqlalchemy sqlalchemy httplib2 simplejson mysql-connector requests pyjwt`
Copy `configs.template.py` as `configs.py` and update the file as needed.
If needed, copy `.env.development` as `.env.development.local` and update the file.

Expand Down
6 changes: 5 additions & 1 deletion api/global_scoreboard_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

@api.route('/players', methods=('GET',))
def get_all_players():
return jsonify(map_to_dto(Player.get_all()))
country_code_str: Optional[str] = request.args.get('region')
if country_code_str is None:
return jsonify(map_to_dto(Player.get_all()))
country_codes = list(set(country_code_str.split(',')))
return jsonify(Player.get_by_country_code(country_codes)), 200, {'Access-Control-Allow-Origin': '*'}


@api.route('/players/<id>/score-details', methods=('GET',))
Expand Down
2 changes: 1 addition & 1 deletion configs.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
sql_connector: str = "mysqlconnector"
sql_username: str = "admin"
sql_password: str = "admin"
sql_hostname: str = "localhost:3356"
sql_hostname: str = "localhost:3306"
sql_database_name: str = "speedrun_global_scoreboard"
3 changes: 1 addition & 2 deletions flask_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3.7
# -*- coding: utf-8 -*-

##########################################################################
Expand All @@ -20,7 +20,6 @@
#
# Contact:
# [email protected]
# api.core_api import api as core_api
##########################################################################
from api.core_api import api as core_api
from api.game_search_api import api as game_search_api
Expand Down
1 change: 0 additions & 1 deletion global-scoreboard/.eslintignore

This file was deleted.

This file was deleted.

Loading

0 comments on commit c683522

Please sign in to comment.