forked from OSQA/osqa
-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* models/analitics.py - added HourlyUserSummary and HourlyGroupSummary these models have an additional field "hour" - renamed UserDailySummary and GroupDailySummary to DailyUserSummary and DailyGroupSummary - added last_summarized_at to Session - renames compiled to summarized in Event, DailyUserSummary, DailyGroupSummary use summarised field in the new models HourlyUserSummary and HourlyGroupSummary as well * updates and renames migrations to reflect the model and field name changes * management command askbot_compile_analytics_events - populates HourlyUserSummary and HourlyGroupSummary in addition to DailyUserSummary and DailyGroupSummary - HourlyUserSummary and HourlyGroupSummary are summarized only after the hour is completed
- Loading branch information
1 parent
9a9fc37
commit d8de648
Showing
7 changed files
with
239 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
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,29 @@ | ||
# Generated by Django 4.2.4 on 2024-07-22 15:52 | ||
# edited by hand to add the populate_last_summarized_at function | ||
# and remove the null=True from the field | ||
from django.db import migrations, models | ||
|
||
def populate_last_summarized_at(apps, schema_editor): | ||
Session = apps.get_model('askbot', 'Session') | ||
Session.objects.all().update(last_summarized_at=models.F('created_at')) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('askbot', '0030_event_summarized_group_used_for_analytics_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='session', | ||
name='last_summarized_at', | ||
field=models.DateTimeField(null=True), | ||
), | ||
migrations.RunPython(populate_last_summarized_at, reverse_code=migrations.RunPython.noop), | ||
migrations.AlterField( | ||
model_name='session', | ||
name='last_summarized_at', | ||
field=models.DateTimeField(null=False) | ||
), | ||
] |
54 changes: 54 additions & 0 deletions
54
askbot/migrations/0032_hourlyusersummary_hourlygroupsummary.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,54 @@ | ||
# Generated by Django 4.2.4 on 2024-07-28 21:52 | ||
|
||
import datetime | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('askbot', '0031_session_last_summarized_at'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='HourlyUserSummary', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('num_questions', models.PositiveIntegerField(default=0)), | ||
('num_answers', models.PositiveIntegerField(default=0)), | ||
('num_upvotes', models.PositiveIntegerField(default=0)), | ||
('num_downvotes', models.PositiveIntegerField(default=0)), | ||
('question_views', models.PositiveIntegerField(default=0)), | ||
('time_on_site', models.DurationField(default=datetime.timedelta(0))), | ||
('summarized', models.BooleanField(default=False)), | ||
('hour', models.DateTimeField(db_index=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='HourlyGroupSummary', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('num_questions', models.PositiveIntegerField(default=0)), | ||
('num_answers', models.PositiveIntegerField(default=0)), | ||
('num_upvotes', models.PositiveIntegerField(default=0)), | ||
('num_downvotes', models.PositiveIntegerField(default=0)), | ||
('question_views', models.PositiveIntegerField(default=0)), | ||
('time_on_site', models.DurationField(default=datetime.timedelta(0))), | ||
('summarized', models.BooleanField(default=False)), | ||
('hour', models.DateTimeField(db_index=True)), | ||
('num_users', models.PositiveIntegerField(default=0)), | ||
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='askbot.group')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
), | ||
] |
Oops, something went wrong.