Skip to content

Commit

Permalink
Implements Riot Sign On (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwanok authored Apr 6, 2024
1 parent 272da1e commit 218201a
Show file tree
Hide file tree
Showing 26 changed files with 1,793 additions and 298 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/elastic-beanstalk-deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Rename docker-compose.prod.yml to docker-compose.yml
run: mv docker-compose.prod.yml docker-compose.yml

- name: Remove docker-compose.dev.yml
run: rm -f docker-compose.dev.yml

- name: Copy Elastic Beanstalk Config
run: |
mkdir -p .elasticbeanstalk
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,6 @@ cython_debug/
!.elasticbeanstalk/*.global.yml


.idea/
.idea/

.ssl/
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: server
server:
@echo "Starting server..."
@poetry run python project/manage.py runserver 22145


.PHONY: infra
infra:
@echo "Starting infra..."
@docker-compose -f docker-compose-dev.yaml up -d --force-recreate --build
23 changes: 23 additions & 0 deletions default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;
server_name local.duofinder.kr;
location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
server_name local.duofinder.kr;

ssl_certificate /etc/nginx/ssl/local.duofinder.kr.pem;
ssl_certificate_key /etc/nginx/ssl/local.duofinder.kr-key.pem;

location / {
proxy_pass http://localhost:22145;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
33 changes: 33 additions & 0 deletions docker-compose-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "3.8"

services:
duofinder-postgres:
image: postgres:16.2
ports:
- "5432:5432"
environment:
POSTGRES_USER: duofinder
POSTGRES_PASSWORD: duofinder
POSTGRES_DB: duofinder
volumes:
- duofinder-postgres:/var/lib/postgresql/data

duofinder-minio:
image: minio/minio:latest
ports:
- "9000:9000"
- "9001:9001"
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
volumes:
- duofinder-minio:/data
command:
server /data --console-address ":9001"

volumes:
duofinder-postgres:
external: true
duofinder-minio:
external: true

File renamed without changes.
4 changes: 0 additions & 4 deletions league_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ async def get_league_entries(self, tier: str, division: str):
league_entries = await self._fetch(url + f"&page={page}")

while league_entries:
print(
f"Fetching {tier} {division} page {page}... entries: {len(league_entries)}"
)
summoners = [
(
league_entry["summonerId"],
Expand Down Expand Up @@ -132,7 +129,6 @@ async def _fetch(self, url: str) -> list:

while response.status == 429:
retry_after = response.headers.get("Retry-After")
print(f"Retrying after {retry_after} seconds")

await asyncio.sleep(int(retry_after))
response = await self.session.get(url)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Generated by Django 5.0.2 on 2024-04-06 12:07

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("app", "0008_duomatch"),
]

operations = [
migrations.CreateModel(
name="RiotAccount",
fields=[
(
"puuid",
models.CharField(max_length=100, primary_key=True, serialize=False),
),
("game_name", models.CharField(max_length=100)),
("tag_line", models.CharField(max_length=100)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name="RiotSoloRank",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("league_id", models.CharField(max_length=255)),
("queue_type", models.CharField(max_length=255)),
("tier", models.CharField(max_length=255)),
("rank", models.CharField(max_length=255)),
("league_points", models.IntegerField()),
("wins", models.IntegerField()),
("losses", models.IntegerField()),
("veteran", models.BooleanField()),
("inactive", models.BooleanField()),
("fresh_blood", models.BooleanField()),
("hot_streak", models.BooleanField()),
],
),
migrations.CreateModel(
name="RiotToken",
fields=[
(
"id_token",
models.CharField(
max_length=1024, primary_key=True, serialize=False
),
),
("access_token", models.CharField(max_length=1024)),
("token_type", models.CharField(max_length=255)),
("expires_in", models.IntegerField()),
("refresh_token", models.CharField(max_length=1024)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name="RiotSummoner",
fields=[
(
"id",
models.CharField(max_length=100, primary_key=True, serialize=False),
),
("puuid", models.CharField(max_length=100)),
("account_id", models.CharField(max_length=100)),
("name", models.CharField(max_length=100)),
("profile_icon_id", models.IntegerField()),
("revision_date", models.BigIntegerField()),
("summoner_level", models.IntegerField()),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"riot_solo_rank",
models.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="app.riotsolorank",
),
),
],
),
migrations.AddField(
model_name="riotsolorank",
name="riot_summoner",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to="app.riotsummoner"
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by Django 5.0.2 on 2024-04-06 15:18

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("app", "0009_riotaccount_riotsolorank_riottoken_riotsummoner_and_more"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AddField(
model_name="duomatch",
name="updated_at",
field=models.DateTimeField(auto_now=True),
),
migrations.CreateModel(
name="DuoMatchFeedback",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("rating", models.CharField(max_length=255)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"duo_match",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="app.duomatch"
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]
59 changes: 59 additions & 0 deletions project/app/migrations/0011_duomatchreport_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Generated by Django 5.0.2 on 2024-04-06 16:47

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("app", "0010_duomatch_updated_at_duomatchfeedback"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="DuoMatchReport",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("reason", models.TextField()),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
),
migrations.AddConstraint(
model_name="duomatchfeedback",
constraint=models.UniqueConstraint(
fields=("duo_match", "user"), name="unique_duo_match_feedback"
),
),
migrations.AddField(
model_name="duomatchreport",
name="duo_match",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="app.duomatch"
),
),
migrations.AddField(
model_name="duomatchreport",
name="user",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
migrations.AddConstraint(
model_name="duomatchreport",
constraint=models.UniqueConstraint(
fields=("duo_match", "user"), name="unique_duo_match_report"
),
),
]
Loading

0 comments on commit 218201a

Please sign in to comment.