Skip to content

Commit

Permalink
add name to get highscore
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Feb 3, 2024
1 parent 03d9a90 commit 72cc983
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
27 changes: 13 additions & 14 deletions notes.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# kubectl
```sh
kubectl port-forward -n kafka svc/bd-prd-kafka-service 9094:9094
kubectl port-forward -n database svc/mysql 3306:3306
```

# setup
## windows
```sh
python -m venv .venv
.venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
```
## linux
```sh
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
```

```sh
.venv\Scripts\activate
pip freeze > requirements.txt
```

# linux / wsl
### tips linux / wsl
to open vscode in wsl just open vs code, type `wsl` in the terminal than type `code .`

tip: you can trim your command line path with
Expand All @@ -27,14 +31,9 @@ add at the botom, exit nano with ctrl + x then press y to save
```sh
PROMPT_DIRTRIM=3
```
restart your shell

# kubectl
```sh
sudo apt update -y && sudo apt upgrade -y
sudo apt install python3.10-venv -y
```
```sh
python3 -m venv .venv
touch .venv\bin\activate
kubectl port-forward -n kafka svc/bd-prd-kafka-service 9094:9094
kubectl port-forward -n database svc/mysql 3306:3306
```
```sh
9 changes: 6 additions & 3 deletions src/app/repositories/highscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
PlayerHiscoreDataLatest,
# PlayerHiscoreDataXPChange,
)
from src.core.database.models.player import Player
from src.core.database.database import SessionFactory
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncResult, AsyncSession
from sqlalchemy.ext.asyncio import AsyncResult
from sqlalchemy.sql.expression import Select
from fastapi.encoders import jsonable_encoder
from src.app.repositories.abstract_repo import AbstractAPI
Expand All @@ -26,12 +27,14 @@ async def _simple_execute(self, sql) -> dict:
return jsonable_encoder(result)

async def get(self, id: int):
sql: Select = select(self.table)
sql: Select = select(self.table, Player.name)
sql = sql.join(target=Player, onclause=self.table.Player_id == Player.id)
sql = sql.where(self.table.Player_id == id)
return await self._simple_execute(sql)

async def get_many(self, start: int, limit: int = 5000):
sql: Select = select(self.table)
sql: Select = select(self.table, Player.name)
sql = sql.join(target=Player, onclause=self.table.Player_id == Player.id)
sql = sql.where(self.table.Player_id > start)
sql = sql.limit(limit)
return await self._simple_execute(sql)
Expand Down
2 changes: 1 addition & 1 deletion src/app/repositories/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from src.core.database.database import SessionFactory
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncResult, AsyncSession
from sqlalchemy.ext.asyncio import AsyncResult
from sqlalchemy.sql.expression import Select
from fastapi.encoders import jsonable_encoder

Expand Down

0 comments on commit 72cc983

Please sign in to comment.