-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,671 additions
and
1,377 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
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
43 changes: 43 additions & 0 deletions
43
concordia/migrations/0097_alter_sitereport_options_userprofile_review_count_and_more.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,43 @@ | ||
# Generated by Django 4.2.13 on 2024-07-29 17:30 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("concordia", "0096_transcription_source"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="sitereport", | ||
options={"get_latest_by": "created_on", "ordering": ("-created_on",)}, | ||
), | ||
migrations.AddField( | ||
model_name="userprofile", | ||
name="review_count", | ||
field=models.IntegerField( | ||
default=0, verbose_name="transcription review count" | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="userprofile", | ||
name="transcribe_count", | ||
field=models.IntegerField( | ||
default=0, verbose_name="transcription save/submit count" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="userprofile", | ||
name="user", | ||
field=models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="profile", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
] |
40 changes: 40 additions & 0 deletions
40
concordia/migrations/0098_userprofile_create_and_population.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,40 @@ | ||
# Generated by Django 4.2.13 on 2024-07-29 17:40 | ||
|
||
from django.conf import settings | ||
from django.db import migrations | ||
|
||
|
||
def create_and_populate_profiles(apps, schema_editor): | ||
User = apps.get_model("auth", "User") | ||
UserProfile = apps.get_model("concordia", "UserProfile") | ||
db_alias = schema_editor.connection.alias | ||
for user in User.objects.using(db_alias).all().iterator(chunk_size=10000): | ||
profile, created = UserProfile.objects.using(db_alias).get_or_create(user=user) | ||
for activity in user.userprofileactivity_set.all(): | ||
profile.transcribe_count += activity.transcribe_count | ||
profile.review_count += activity.review_count | ||
profile.save() | ||
|
||
|
||
def revert_create_and_populate_profiles(apps, schema_editor): | ||
# We can't actually revert the data to the state it was before, | ||
# and there's no actual need to, but we need this function to be | ||
# able to reverse this migration | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
( | ||
"concordia", | ||
"0097_alter_sitereport_options_userprofile_review_count_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
create_and_populate_profiles, revert_create_and_populate_profiles | ||
), | ||
] |
Oops, something went wrong.