Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimap API v0.1 - Initial release #148

Merged
merged 20 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d661be0
Optimize Player Full Karma querying and update DTO
SakuraIsayeki Jul 1, 2023
149a431
feat(minimap): Add initial files & structure for `wowskarma.api.minimap`
SakuraIsayeki Jul 19, 2023
1786888
ci: Add CI workflow for Minimap API
SakuraIsayeki Jul 19, 2023
1c03fae
refactor: Change project file structure
SakuraIsayeki Jul 19, 2023
fa5668a
feat: Update docker-compose and app configuration
SakuraIsayeki Jul 19, 2023
a6fc27d
feat: Update app description and security
SakuraIsayeki Jul 19, 2023
30f7145
feat(routes): Remove content routes & update user creation functionality
SakuraIsayeki Jul 19, 2023
170c135
feat(render): Add render route for replay rendering
SakuraIsayeki Jul 20, 2023
fb5e850
feat(render): Update requirements and add target player ID support
SakuraIsayeki Jul 20, 2023
20bc0ef
Merge branch 'feature/minimap-rendering' into develop
SakuraIsayeki Jul 20, 2023
65e95d1
fix(ci): Update python-version matrix in minimap-main.yml
SakuraIsayeki Jul 20, 2023
b26ea12
fix(ci): Update directory name in minimap-main.yml
SakuraIsayeki Jul 20, 2023
a2f1df6
ci: Add Docker build and push workflows for Minimap API
SakuraIsayeki Jul 20, 2023
310e512
ci: Refactor Minimap API build and push workflows
SakuraIsayeki Jul 20, 2023
bd9b553
feat(minimap_api_security): Improve get_current_user function
SakuraIsayeki Jul 20, 2023
90b3e5a
feat(render): Add background task for removing temporary file
SakuraIsayeki Jul 21, 2023
192acb1
feat(cli): Remove unused import and variable
SakuraIsayeki Jul 21, 2023
52ded6b
feat(render): Add logging for new render job
SakuraIsayeki Jul 21, 2023
8b0bef4
feat(render): Add fps and quality options to replay rendering
SakuraIsayeki Jul 21, 2023
2dca693
Merge branch 'feature/minimap-rendering' into develop
SakuraIsayeki Jul 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/minimap-api-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build Minimap API Docker Image

on:
push:
workflow_dispatch:


jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Build Docker Image
run: docker build -f wowskarma_api_minimap/Dockerfile.dev -t wowskarma_api_minimap:tag ./wowskarma_api_minimap
39 changes: 39 additions & 0 deletions .github/workflows/minimap-api-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Push Minimap API Docker Image

on:
workflow_dispatch:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dockerhub: [
# { registry: "docker.io", username: "${{ secrets.DOCKERHUB_USERNAME }}", password: "${{ secrets.DOCKERHUB_TOKEN }}" },
{ registry: "ghcr.io", username: "${{ github.actor }}", password: "${{ github.token }}" }
]

steps:
- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: ${{ matrix.dockerhub.registry }}
username: ${{ matrix.dockerhub.username }}
password: ${{ matrix.dockerhub.password }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: wowskarma_api_minimap:latest,wowskarma_api_minimap:$(date +%Y%m%d),wowskarma_api_minimap:$(git rev-parse --short HEAD)
12 changes: 8 additions & 4 deletions WowsKarma.Api/Services/PlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ public async Task<Player> GetPlayerAsync(uint accountId, bool includeRelated = f
return player;
}

public IQueryable<AccountFullKarmaDTO> GetPlayersFullKarma(IEnumerable<uint> accountIds)
private static readonly Func<ApiDbContext, IEnumerable<uint>, IEnumerable<AccountFullKarmaDTO>> CompiledPlayersFullKarmaQuery =
EF.CompileQuery(static (ApiDbContext db, IEnumerable<uint> accountIds) => db.Players.AsNoTracking()
.Where(p => accountIds.Contains(p.Id))
.Select(p => new AccountFullKarmaDTO(p.Id, p.GameKarma, p.SiteKarma, p.PerformanceRating, p.TeamplayRating, p.CourtesyRating)));

public IEnumerable<AccountFullKarmaDTO> GetPlayersFullKarma(IEnumerable<uint> accountIds)
{
return from p in _context.Players.AsNoTracking()
where accountIds.Contains(p.Id)
select new AccountFullKarmaDTO(p.Id, p.SiteKarma, p.PerformanceRating, p.TeamplayRating, p.CourtesyRating);
// Use the compiled query
return CompiledPlayersFullKarmaQuery.Invoke(_context, accountIds);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion WowsKarma.Common/Models/DTOs/AccountKarmaDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


// Used by WOWS Monitor
public record AccountFullKarmaDTO(uint Id, int Karma, int Performance, int Teamplay, int Courtesy) : AccountKarmaDTO(Id, Karma);
public record AccountFullKarmaDTO(uint Id, int GameKarma, int PlatformKarma, int Performance, int Teamplay, int Courtesy) : AccountKarmaDTO(Id, PlatformKarma);

public record AccountKarmaDTO(uint Id, int Karma)
{
Expand Down
8 changes: 8 additions & 0 deletions wowskarma_api_minimap/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
source = wowskarma_api_minimap

[report]
omit =
*/python?.?/*
*/site-packages/nose/*
wowskarma_api_minimap/__main__.py
137 changes: 137 additions & 0 deletions wowskarma_api_minimap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# db files
*.db

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# templates
.github/templates/*
.idea/

18 changes: 18 additions & 0 deletions wowskarma_api_minimap/.secrets.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[development]
dynaconf_merge = true

[development.security]
# openssl rand -hex 32
SECRET_KEY = "ONLYFORDEVELOPMENT"

[production]
dynaconf_merge = true

[production.security]
SECRET_KEY = "@vault path/to/vault/secret"

[testing]
dynaconf_merge = true

[testing.security]
SECRET_KEY = "ONLYFORTESTING"
Loading