-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add * pass * Update get_producer.py * add * Maybe * fix dockerfile * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
cf7c7ea
commit 2c72472
Showing
35 changed files
with
402 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
until cd /code | ||
do | ||
echo "Waiting for server volume..." | ||
done | ||
|
||
# run a worker :) | ||
export PYTHONPATH=$PYTHONPATH:/code/django_core:/code | ||
|
||
celery -A django_core.core beat -l info |
18 changes: 18 additions & 0 deletions
18
backend/django_core/apps/anime/migrations/0010_animemodel_is_locked.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2 on 2023-04-24 07:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("anime", "0009_animegenremodel_description"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="animemodel", | ||
name="is_locked", | ||
field=models.BooleanField(default=False), | ||
preserve_default=False, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
49 changes: 49 additions & 0 deletions
49
backend/django_core/apps/characters/management/commands/get_character.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import sys | ||
from typing import NoReturn | ||
|
||
import httpx | ||
|
||
from shinobi.parser.character import CharacterParser | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from ...models import CharacterModel | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Django command that gets the Character Information given mal_id" | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
self.client = httpx.Client() | ||
super().__init__(*args, **kwargs) | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"character_number", | ||
type=int, | ||
help="The character number to get information for", | ||
) | ||
|
||
def handle(self, *args, **options) -> NoReturn: | ||
character_number: int = options["character_number"] | ||
res = self.client.get(f"https://myanimelist.net/character/{character_number}") | ||
|
||
parser = CharacterParser(res.content) | ||
data_dictionary = parser.build_dictionary() | ||
|
||
try: | ||
character_instance = CharacterModel.objects.get(mal_id=character_number) | ||
except CharacterModel.DoesNotExist: | ||
self.stdout.write( | ||
f"No CharacterModel found for {self.style.ERROR(character_number)}" | ||
) | ||
sys.exit(1) | ||
|
||
for attr, value in data_dictionary.items(): | ||
if value: | ||
setattr(character_instance, attr, value) | ||
|
||
character_instance.save() | ||
self.stdout.write( | ||
f"Successfully got info for {self.style.SUCCESS(character_number)}" | ||
) |
18 changes: 18 additions & 0 deletions
18
backend/django_core/apps/characters/migrations/0003_charactermodel_is_locked.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2 on 2023-04-24 07:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("characters", "0002_charactermodel_created_at_charactermodel_updated_at"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="charactermodel", | ||
name="is_locked", | ||
field=models.BooleanField(default=False), | ||
preserve_default=False, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from celery import shared_task | ||
from shinobi.builder.character import CharacterBuilder | ||
|
||
from django.core.management import call_command | ||
from django.db.models import Q | ||
from django.utils import timezone | ||
|
||
from .models import CharacterModel | ||
|
||
|
||
@shared_task() | ||
def get_perodic_character(): | ||
builder = CharacterBuilder() | ||
|
||
instances = CharacterModel.objects.filter( | ||
Q(updated_at__gte=timezone.now() - timezone.timedelta(days=7)) & Q(is_locked=False) | ||
) | ||
dictionary = builder.build_dictionary(excluded_ids=instances.values_list(flat=True)) | ||
|
||
for anime in list(dictionary.keys()): | ||
call_command("get_character", character_id=anime) |
Empty file.
Empty file.
49 changes: 49 additions & 0 deletions
49
backend/django_core/apps/producers/management/commands/get_producer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import sys | ||
from typing import NoReturn | ||
|
||
import httpx | ||
|
||
from shinobi.parser.producer import ProducerParser | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from ...models import ProducerModel | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Django command that gets the Producer Information given mal_id" | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
self.client = httpx.Client() | ||
super().__init__(*args, **kwargs) | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"producer_number", | ||
type=int, | ||
help="The producer number to get information for", | ||
) | ||
|
||
def handle(self, *args, **options) -> NoReturn: | ||
producer_number: int = options["producer_number"] | ||
res = self.client.get(f"https://myanimelist.net/anime/producer/{producer_number}") | ||
|
||
parser = ProducerParser(res.content) | ||
data_dictionary = parser.build_dictionary() | ||
|
||
try: | ||
producer_instance = ProducerModel.objects.get(mal_id=producer_number) | ||
except ProducerModel.DoesNotExist: | ||
self.stdout.write( | ||
f"No ProducerModel found for {self.style.ERROR(producer_number)}" | ||
) | ||
sys.exit(1) | ||
|
||
for attr, value in data_dictionary.items(): | ||
if value: | ||
setattr(producer_instance, attr, value) | ||
|
||
producer_instance.save() | ||
self.stdout.write( | ||
f"Successfully got info for {self.style.SUCCESS(producer_number)}" | ||
) |
18 changes: 18 additions & 0 deletions
18
backend/django_core/apps/producers/migrations/0005_producermodel_is_locked.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2 on 2023-04-24 07:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("producers", "0004_rename_japanese_title_producermodel_name_japanese"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="producermodel", | ||
name="is_locked", | ||
field=models.BooleanField(default=False), | ||
preserve_default=False, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
45 changes: 45 additions & 0 deletions
45
backend/django_core/apps/staffs/management/commands/get_staff.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import sys | ||
from typing import NoReturn | ||
|
||
import httpx | ||
|
||
from shinobi.parser.staff import StaffParser | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from ...models import StaffModel | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Django command that gets the Staff Information given mal_id" | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
self.client = httpx.Client() | ||
super().__init__(*args, **kwargs) | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"staff_number", | ||
type=int, | ||
help="The staff number to get information for", | ||
) | ||
|
||
def handle(self, *args, **options) -> NoReturn: | ||
staff_number: int = options["staff_number"] | ||
res = self.client.get(f"https://myanimelist.net/people/{staff_number}") | ||
|
||
parser = StaffParser(res.content) | ||
data_dictionary = parser.build_dictionary() | ||
|
||
try: | ||
staff_instance = StaffModel.objects.get(mal_id=staff_number) | ||
except StaffModel.DoesNotExist: | ||
self.stdout.write(f"No StaffModel found for {self.style.ERROR(staff_number)}") | ||
sys.exit(1) | ||
|
||
for attr, value in data_dictionary.items(): | ||
if value: | ||
setattr(staff_instance, attr, value) | ||
|
||
staff_instance.save() | ||
self.stdout.write(f"Successfully got info for {self.style.SUCCESS(staff_number)}") |
18 changes: 18 additions & 0 deletions
18
backend/django_core/apps/staffs/migrations/0004_staffmodel_is_locked.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2 on 2023-04-24 07:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("staffs", "0003_staffmodel_created_at_staffmodel_updated_at"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="staffmodel", | ||
name="is_locked", | ||
field=models.BooleanField(default=False), | ||
preserve_default=False, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.db import models | ||
|
||
|
||
class IsLockedMixin(models.Model): | ||
is_locked = models.BooleanField() | ||
|
||
class Meta: | ||
abstract = True |
Oops, something went wrong.
2c72472
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
coreproject – ./
coreproject-baseplate-admin.vercel.app
coreproject-git-master-baseplate-admin.vercel.app
core-project.vercel.app
coreproject.vercel.app
coreproject.moe