Skip to content

Commit

Permalink
Merge pull request #148 from SakuraIsayeki/develop
Browse files Browse the repository at this point in the history
Minimap API v0.1 - Initial release
  • Loading branch information
SakuraIsayeki authored Jul 21, 2023
2 parents 74cd0b9 + 2dca693 commit 2fa755a
Show file tree
Hide file tree
Showing 44 changed files with 2,354 additions and 5 deletions.
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

0 comments on commit 2fa755a

Please sign in to comment.