Refactor and remove tests, update models and views
- Deleted all test files in accounts and twitch apps to clean up the codebase. - Updated the DropCampaign, Game, Organization, DropBenefit, TimeBasedDrop, and DropBenefitEdge models to include database indexing for improved query performance. - Modified the DropCampaignListView and GameDetailView to remove unnecessary status filtering and streamline campaign retrieval logic. - Enhanced the campaign detail template to properly format campaign descriptions. - Adjusted the import_drop_campaign management command to increase default worker and batch sizes for improved performance. - Cleaned up the admin configuration for DropCampaign and TimeBasedDrop models.
This commit is contained in:
parent
547d4e6ab1
commit
8f4e851fb9
16 changed files with 193 additions and 741 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 5.2.4 on 2025-07-09 20:44
|
||||
# Generated by Django 5.2.4 on 2025-07-23 23:51
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
|
@ -16,27 +16,12 @@ class Migration(migrations.Migration):
|
|||
name='DropBenefit',
|
||||
fields=[
|
||||
('id', models.TextField(primary_key=True, serialize=False)),
|
||||
('name', models.TextField()),
|
||||
('name', models.TextField(db_index=True)),
|
||||
('image_asset_url', models.URLField(blank=True, default='', max_length=500)),
|
||||
('created_at', models.DateTimeField()),
|
||||
('created_at', models.DateTimeField(db_index=True)),
|
||||
('entitlement_limit', models.PositiveIntegerField(default=1)),
|
||||
('is_ios_available', models.BooleanField(default=False)),
|
||||
('distribution_type', models.TextField(choices=[('DIRECT_ENTITLEMENT', 'Direct Entitlement'), ('CODE', 'Code')])),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Game',
|
||||
fields=[
|
||||
('id', models.TextField(primary_key=True, serialize=False)),
|
||||
('slug', models.TextField(blank=True, default='')),
|
||||
('display_name', models.TextField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Organization',
|
||||
fields=[
|
||||
('id', models.TextField(primary_key=True, serialize=False)),
|
||||
('name', models.TextField()),
|
||||
('distribution_type', models.TextField(choices=[('DIRECT_ENTITLEMENT', 'Direct Entitlement'), ('CODE', 'Code')], db_index=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
|
|
@ -47,23 +32,43 @@ class Migration(migrations.Migration):
|
|||
('benefit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='twitch.dropbenefit')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Game',
|
||||
fields=[
|
||||
('id', models.TextField(primary_key=True, serialize=False)),
|
||||
('slug', models.TextField(blank=True, db_index=True, default='')),
|
||||
('display_name', models.TextField(db_index=True)),
|
||||
],
|
||||
options={
|
||||
'indexes': [models.Index(fields=['slug'], name='twitch_game_slug_a02d3c_idx'), models.Index(fields=['display_name'], name='twitch_game_display_a35ba3_idx')],
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='dropbenefit',
|
||||
name='game',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='drop_benefits', to='twitch.game'),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Organization',
|
||||
fields=[
|
||||
('id', models.TextField(primary_key=True, serialize=False)),
|
||||
('name', models.TextField(db_index=True)),
|
||||
],
|
||||
options={
|
||||
'indexes': [models.Index(fields=['name'], name='twitch_orga_name_febe72_idx')],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='DropCampaign',
|
||||
fields=[
|
||||
('id', models.TextField(primary_key=True, serialize=False)),
|
||||
('name', models.TextField()),
|
||||
('name', models.TextField(db_index=True)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('details_url', models.URLField(blank=True, default='', max_length=500)),
|
||||
('account_link_url', models.URLField(blank=True, default='', max_length=500)),
|
||||
('image_url', models.URLField(blank=True, default='', max_length=500)),
|
||||
('start_at', models.DateTimeField()),
|
||||
('end_at', models.DateTimeField()),
|
||||
('status', models.TextField(choices=[('ACTIVE', 'Active'), ('UPCOMING', 'Upcoming'), ('EXPIRED', 'Expired')])),
|
||||
('start_at', models.DateTimeField(db_index=True)),
|
||||
('end_at', models.DateTimeField(db_index=True)),
|
||||
('is_account_connected', models.BooleanField(default=False)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
|
|
@ -80,11 +85,11 @@ class Migration(migrations.Migration):
|
|||
name='TimeBasedDrop',
|
||||
fields=[
|
||||
('id', models.TextField(primary_key=True, serialize=False)),
|
||||
('name', models.TextField()),
|
||||
('required_minutes_watched', models.PositiveIntegerField()),
|
||||
('name', models.TextField(db_index=True)),
|
||||
('required_minutes_watched', models.PositiveIntegerField(db_index=True)),
|
||||
('required_subs', models.PositiveIntegerField(default=0)),
|
||||
('start_at', models.DateTimeField()),
|
||||
('end_at', models.DateTimeField()),
|
||||
('start_at', models.DateTimeField(db_index=True)),
|
||||
('end_at', models.DateTimeField(db_index=True)),
|
||||
('benefits', models.ManyToManyField(related_name='drops', through='twitch.DropBenefitEdge', to='twitch.dropbenefit')),
|
||||
('campaign', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='time_based_drops', to='twitch.dropcampaign')),
|
||||
],
|
||||
|
|
@ -94,6 +99,62 @@ class Migration(migrations.Migration):
|
|||
name='drop',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='twitch.timebaseddrop'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropcampaign',
|
||||
index=models.Index(fields=['name'], name='twitch_drop_name_3b70b3_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropcampaign',
|
||||
index=models.Index(fields=['start_at', 'end_at'], name='twitch_drop_start_a_6e5fb6_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropcampaign',
|
||||
index=models.Index(fields=['game'], name='twitch_drop_game_id_868e70_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropcampaign',
|
||||
index=models.Index(fields=['owner'], name='twitch_drop_owner_i_37241d_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropbenefit',
|
||||
index=models.Index(fields=['name'], name='twitch_drop_name_7125ff_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropbenefit',
|
||||
index=models.Index(fields=['created_at'], name='twitch_drop_created_a3563e_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropbenefit',
|
||||
index=models.Index(fields=['distribution_type'], name='twitch_drop_distrib_08b224_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropbenefit',
|
||||
index=models.Index(fields=['game'], name='twitch_drop_game_id_a9209e_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropbenefit',
|
||||
index=models.Index(fields=['owner_organization'], name='twitch_drop_owner_o_45b4cc_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='timebaseddrop',
|
||||
index=models.Index(fields=['name'], name='twitch_time_name_47c0f4_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='timebaseddrop',
|
||||
index=models.Index(fields=['start_at', 'end_at'], name='twitch_time_start_a_c481f1_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='timebaseddrop',
|
||||
index=models.Index(fields=['campaign'], name='twitch_time_campaig_bbe349_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='timebaseddrop',
|
||||
index=models.Index(fields=['required_minutes_watched'], name='twitch_time_require_82c30c_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dropbenefitedge',
|
||||
index=models.Index(fields=['drop', 'benefit'], name='twitch_drop_drop_id_5a574c_idx'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='dropbenefitedge',
|
||||
unique_together={('drop', 'benefit')},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue