Skip to content
Merged

7.51 #99

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/api/tasks/db_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class DBCleanupTask(PeriodicTask):
run_every = '0 * * * *'
run_every = '0 0 * * *'

def run(self):
"""
Expand Down
13 changes: 2 additions & 11 deletions backend/api/tasks/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from django.conf import settings
from django.core.management import call_command
from django.db import IntegrityError
from django_cloud_tasks.serializers import serialize
from django_cloud_tasks.tasks import SubscriberTask
# local
from .base import SavageAimPublisherTask
Expand All @@ -33,18 +32,10 @@ def run(
headers: dict[str, str] | None = None,
):
if settings.DJANGO_CLOUD_TASKS_EAGER:
return SeedTaskSubscriber().run(output=StringIO(), **message) # fake io for hiding io during tests
return SeedTaskSubscriber().run(output=StringIO()) # fake io for hiding io during tests

# Real override to fix a bug in the library
# Cloud PubSub does not support headers, but we simulate them with a key in the data property
message = self._build_message_with_headers(message=message, headers=headers)
message['attributes'] = attributes

return self._get_publisher_client().publish(
message=serialize(value=message),
topic_id=self.topic_name(),
attributes=attributes,
)
super().run(message, attributes, headers)


class SeedTaskSubscriber(SubscriberTask):
Expand Down
2 changes: 1 addition & 1 deletion backend/api/tasks/verification_reminder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class VerificationReminderTask(PeriodicTask):
run_every = '0 * * * *'
run_every = '0 0 * * *'

def run(self):
"""
Expand Down
14 changes: 13 additions & 1 deletion backend/api/tasks/verify_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from channels.layers import get_channel_layer
from django.conf import settings
from django.db.models import Q
from django_cloud_tasks.serializers import serialize
from django_cloud_tasks.tasks import SubscriberTask

from .base import SavageAimPublisherTask
Expand All @@ -21,6 +20,19 @@ class VerifyCharacterTask(SavageAimPublisherTask):
def topic_name(cls) -> str:
return TOPIC_NAME

# Define run command that runs the subscriber during eager environments
def run(
self,
message: dict,
attributes: dict[str, str] | None = None,
headers: dict[str, str] | None = None,
):
if settings.DJANGO_CLOUD_TASKS_EAGER:
return VerifyCharacterTaskSubscriber().run(content=message, output=StringIO()) # for hiding io during tests

# Real override to fix a bug in the library
super().run(message, attributes, headers)


class VerifyCharacterTaskSubscriber(SubscriberTask):

Expand Down
11 changes: 7 additions & 4 deletions backend/api/tests/test_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
from api import notifier
from api.models import BISList, Character, Gear, Notification, Job, Settings, Team, Tier
from api.serializers import CharacterCollectionSerializer, CharacterDetailsSerializer
from api.tasks import VerifyCharacterTask
from .test_base import SavageAimTestCase


def _fake_task(pk: int, **kwargs):
def _fake_task(content: dict, **kwargs):
"""
Handle what celery would handle if it were running
"""
pk = content['pk']
try:
obj = Character.objects.get(pk=pk)
except Character.DoesNotExist: # pragma: no cover
Expand Down Expand Up @@ -369,7 +371,8 @@ def test_verify(self, mocked_task):
self.assertEqual(notif.type, 'verify_success')
self.assertFalse(notif.read)

def test_verify_fail_notifs(self):
@patch('api.tasks.verify_character.VerifyCharacterTaskSubscriber.run', side_effect=_fake_task)
def test_verify_fail_notifs(self, *args):
"""
Just call the mock task with a verified character and test the notifier task works
Also test after changing the notif settings to ensure a second notif isn't sent
Expand All @@ -383,7 +386,7 @@ def test_verify_fail_notifs(self):
world='Lich',
verified=True,
)
_fake_task(char.id)
VerifyCharacterTask.sync(dict(pk=char.pk))

# Check Notification was created properly
self.assertEqual(Notification.objects.filter(user=user).count(), 1)
Expand All @@ -395,7 +398,7 @@ def test_verify_fail_notifs(self):

# Update settings and try again
Settings.objects.create(user=user, theme='beta', notifications={'verify_fail': False})
_fake_task(char.id)
VerifyCharacterTask.sync(dict(pk=char.pk))
self.assertEqual(Notification.objects.filter(user=user).count(), 1)

@patch('api.tasks.verify_character.VerifyCharacterTaskSubscriber.run', side_effect=_fake_task)
Expand Down
2 changes: 1 addition & 1 deletion backend/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '20260530'
VERSION = '20260602'
14 changes: 6 additions & 8 deletions backend/backend/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.discord',

# Cloud Tasks
'django_cloud_tasks',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -163,13 +166,8 @@
LOGOUT_REDIRECT_URL = '/'
SOCIALACCOUNT_LOGIN_ON_GET = True

# Celery settings
BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Europe/Dublin'

# Add the webhook for versioning
VERSION_WEBHOOK = environ.get('VERSION_WEBHOOK', None)

# Cloud Tasks
DJANGO_CLOUD_TASKS_EAGER = True
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "savage-aim-backend"
version = "20260530"
version = "20260602"
description = "Django Backend for savageaim.com"
authors = ["freyama.de"]
license = "MIT"
Expand Down
5 changes: 5 additions & 0 deletions backend/seed_data/gear/7-dt/7.51.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 785
name: "Palazzo Diamond"
2 changes: 1 addition & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VUE_APP_VERSION="20260530"
VUE_APP_VERSION="20260602"
9 changes: 6 additions & 3 deletions frontend/src/components/modals/changelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
</div>
<div class="card-content content">
<h2 class="has-text-primary subtitle">{{ version }}</h2>
<div class="divider"><i class="material-icons icon">expand_more</i> Minor Fixes <i class="material-icons icon">expand_more</i></div>
<p>Re-architected how async tasks are run to try and save costs + make them faster (a rare win-win in this industry!)</p>
<p>Also tried a change to improve startup time of the API so requests get answered faster when the site hasn't been used in a while.</p>
<div class="divider"><i class="material-icons icon">expand_more</i> FFXIV 7.51 <i class="material-icons icon">expand_more</i></div>
<p>Added the Palazzo Diamond Weapons, Item Level 795, available from the new Dancing Mad Ultimate.</p>
<p>Best of luck to all proggers!</p>

<div class="divider"><i class="material-icons icon">expand_more</i> Minor Updates <i class="material-icons icon">expand_more</i></div>
<p>Changed the Verification Reminder and Unverified Character Cleanup jobs from hourly to daily to save on costs.</p>
</div>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Sentry.init({
Vue,
dsn: 'https://06f41b525a40497a848fb726f6d03244@o242258.ingest.sentry.io/6180221',
logErrors: true,
release: 'savageaim@20260530',
release: 'savageaim@20260602',
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
Expand Down
Loading