Skip to content

Commit

Permalink
migrating to using auto_prefetch library to hopefully better address …
Browse files Browse the repository at this point in the history
…all the n+1 issues (#80)

* migrating to using auto_prefetch library

* Update xivgear.py
  • Loading branch information
freyamade authored Jul 20, 2024
1 parent 8c20a3d commit 8f364d8
Show file tree
Hide file tree
Showing 15 changed files with 377 additions and 206 deletions.
308 changes: 308 additions & 0 deletions backend/api/migrations/0026_using_auto_prefetch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
# Generated by Django 3.2.25 on 2024-07-19 22:22

import auto_prefetch
from django.conf import settings
from django.db import migrations
import django.db.models.deletion
import django.db.models.manager


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('api', '0025_gear_extra_import_names'),
]

operations = [
migrations.AlterModelOptions(
name='bislist',
options={'base_manager_name': 'prefetch_manager', 'ordering': ['-job__role', 'job__ordering', 'name']},
),
migrations.AlterModelOptions(
name='character',
options={'base_manager_name': 'prefetch_manager'},
),
migrations.AlterModelOptions(
name='gear',
options={'base_manager_name': 'prefetch_manager', 'ordering': ['-item_level', '-id']},
),
migrations.AlterModelOptions(
name='job',
options={'base_manager_name': 'prefetch_manager', 'ordering': ['-role', 'ordering']},
),
migrations.AlterModelOptions(
name='loot',
options={'base_manager_name': 'prefetch_manager', 'ordering': ['-obtained', '-id']},
),
migrations.AlterModelOptions(
name='notification',
options={'base_manager_name': 'prefetch_manager', 'ordering': ['-timestamp']},
),
migrations.AlterModelOptions(
name='settings',
options={'base_manager_name': 'prefetch_manager'},
),
migrations.AlterModelOptions(
name='team',
options={'base_manager_name': 'prefetch_manager'},
),
migrations.AlterModelOptions(
name='teammember',
options={'base_manager_name': 'prefetch_manager', 'ordering': ['-bis_list__job__role', 'bis_list__job__ordering']},
),
migrations.AlterModelOptions(
name='tier',
options={'base_manager_name': 'prefetch_manager', 'ordering': ['-max_item_level']},
),
migrations.AlterModelManagers(
name='bislist',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='character',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='gear',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='job',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='loot',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='notification',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='settings',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='team',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='teammember',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterModelManagers(
name='tier',
managers=[
('objects', django.db.models.manager.Manager()),
('prefetch_manager', django.db.models.manager.Manager()),
],
),
migrations.AlterField(
model_name='bislist',
name='bis_body',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_body_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_bracelet',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_bracelet_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_earrings',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_earrings_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_feet',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_feet_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_hands',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_hands_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_head',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_head_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_left_ring',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_left_ring_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_legs',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_legs_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_mainhand',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_mainhand_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_necklace',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_necklace_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_offhand',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_offhand_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='bis_right_ring',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_right_ring_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_body',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_body_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_bracelet',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_bracelet_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_earrings',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_earrings_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_feet',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_feet_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_hands',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_hands_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_head',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_head_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_left_ring',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_left_ring_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_legs',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_legs_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_mainhand',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_mainhand_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_necklace',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_necklace_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_offhand',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_offhand_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='current_right_ring',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_right_ring_set', to='api.gear'),
),
migrations.AlterField(
model_name='bislist',
name='job',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.job'),
),
migrations.AlterField(
model_name='bislist',
name='owner',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bis_lists', to='api.character'),
),
migrations.AlterField(
model_name='character',
name='user',
field=auto_prefetch.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='loot',
name='member',
field=auto_prefetch.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='api.teammember'),
),
migrations.AlterField(
model_name='loot',
name='team',
field=auto_prefetch.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.team'),
),
migrations.AlterField(
model_name='loot',
name='tier',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='api.tier'),
),
migrations.AlterField(
model_name='notification',
name='user',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='settings',
name='user',
field=auto_prefetch.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='settings', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='team',
name='tier',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.tier'),
),
migrations.AlterField(
model_name='teammember',
name='bis_list',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='api.bislist'),
),
migrations.AlterField(
model_name='teammember',
name='character',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.character'),
),
migrations.AlterField(
model_name='teammember',
name='team',
field=auto_prefetch.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='members', to='api.team'),
),
]
Loading

0 comments on commit 8f364d8

Please sign in to comment.