Skip to content

Commit

Permalink
Don't need season in database
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjp93 committed Oct 26, 2024
1 parent 2f994f6 commit 0eb32e3
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 114 deletions.
7 changes: 1 addition & 6 deletions data/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import admin

from .models import Rito
from .models import Queue, Season, Map
from .models import Queue, Map
from .models import GameMode, GameType
from .models import ReforgedTree, ReforgedRune

Expand Down Expand Up @@ -30,10 +30,6 @@ class QueueAdmin(admin.ModelAdmin):
list_display = ("_map", "_id")


class SeasonAdmin(admin.ModelAdmin):
list_display = ("name", "_id")


class MapAdmin(admin.ModelAdmin):
list_display = ("name", "_id", "minimap_url")

Expand Down Expand Up @@ -213,7 +209,6 @@ class SummonerSpellVarAdmin(admin.ModelAdmin):

admin.site.register(Rito, RitoAdmin)
admin.site.register(Queue, QueueAdmin)
admin.site.register(Season, SeasonAdmin)
admin.site.register(Map, MapAdmin)
admin.site.register(GameMode, GameModeAdmin)
admin.site.register(GameType, GameTypeAdmin)
Expand Down
98 changes: 25 additions & 73 deletions data/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from typing import TypedDict
from enum import StrEnum

from pydantic import BaseModel
from datetime import datetime

from django.utils import timezone


MIN_PASSWORD_LENGTH = 7
Expand Down Expand Up @@ -39,79 +41,29 @@ def get_null_bool(val):
return out


class Season(BaseModel):
start: datetime
end: datetime
patch_start: tuple
patch_end: tuple
name: str


SEASONS = [
{
"_id": 0,
"name": "PRESEASON 3",
},
{
"_id": 1,
"name": "SEASON 3",
},
{
"_id": 2,
"name": "PRESEASON 2014",
},
{
"_id": 3,
"name": "SEASON 2014",
},
{
"_id": 4,
"name": "PRESEASON 2015",
},
{
"_id": 5,
"name": "SEASON 2015",
},
{
"_id": 6,
"name": "PRESEASON 2016",
},
{
"_id": 7,
"name": "SEASON 2016",
},
{
"_id": 8,
"name": "PRESEASON 2017",
},
{
"_id": 9,
"name": "SEASON 2017",
},
{
"_id": 10,
"name": "PRESEASON 2018",
},
{
"_id": 11,
"name": "SEASON 2018",
},
{
"_id": 12,
"name": "PRESEASON 2019",
},
{
"_id": 13,
"name": "SEASON 2019",
},
{
"_id": 14,
"name": "PRESEASON 2020",
},
{
"_id": 15,
"name": "SEASON 2020",
},
{
"_id": 16,
"name": "PRESEASON 2021",
},
{
"_id": 17,
"name": "SEASON 2021",
},
Season(
start=timezone.datetime(2020, 1, 23),
end=timezone.datetime(2020, 11, 10),
patch_start=(10, 1),
patch_end=(10, 22),
name="Season 10",
),
# Season(
# start=timezone.datetime(2020, 1, 23),
# end=timezone.datetime(2020, 11, 10),
# patch_start=(10, 1),
# patch_end=(10, 22),
# name="Season 14 Split 2",
# )
]

FLEX_QUEUE = 440
Expand Down
16 changes: 16 additions & 0 deletions data/migrations/0039_delete_season.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 5.1.2 on 2024-10-26 17:55

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('data', '0038_item_flat_magic_penetration'),
]

operations = [
migrations.DeleteModel(
name='Season',
),
]
8 changes: 0 additions & 8 deletions data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ def get_map(self):
return None


class Season(models.Model):
_id = models.IntegerField(unique=True)
name = models.CharField(max_length=128, default="", blank=True)

def __str__(self):
return f'Season(_id={self._id}, name="{self.name}")'


class Map(models.Model):
_id = models.IntegerField(unique=True)
name = models.CharField(max_length=256, default="", blank=True)
Expand Down
28 changes: 1 addition & 27 deletions data/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from data.parsers.summoner_spells import CDSummonerSpellListParser

from .models import CDProfileIcon, Rito
from .models import Season, Map, Queue
from .models import Map, Queue
from .models import GameMode, GameType
from .models import ReforgedTree, ReforgedRune, CDSummonerSpell

Expand Down Expand Up @@ -97,24 +97,9 @@ def import_last_versions(start, end, language="en_US", overwrite=True):

@app.task(name="data.tasks.import_all")
def import_all(version, language="en_US", overwrite=False, api_only=False):
"""Import all constants data from constants.py and riot api.
Adds data to database
Parameters
----------
version : str
language : str
Returns
-------
None
"""
# import from data.constants.py
logger.info(f"Importing data for version {version}")
if not api_only:
import_seasons()
import_maps()
import_queues()
import_gamemodes()
Expand All @@ -139,17 +124,6 @@ def import_all(version, language="en_US", overwrite=False, api_only=False):
import_reforgedrunes(version=version, language=language, overwrite=overwrite)


def import_seasons():
"""Import seasons from contants.py
"""
for season_data in constants.SEASONS:
season = Season(**season_data)
try:
season.save()
except IntegrityError:
continue


def import_maps():
"""Import maps from constants.py
"""
Expand Down

0 comments on commit 0eb32e3

Please sign in to comment.