zulip/analytics/management/commands
Mateusz Mandera 8acfa17fe6 models: Add recipient foreign key in UserProfile and Stream.
This is adds foreign keys to the corresponding Recipient object in the
UserProfile on Stream tables, a denormalization intended to improve
performance as this is a common query.

In the migration for setting the field correctly for existing users,
we do a direct SQL query (because Django 1.11 doesn't provide any good
method for doing it properly in bulk using the ORM.).

A consequence of this change to the model is that a bit of code needs
to be added to the functions responsible for creating new users (to
set the field after the Recipient object gets created).  Fortunately,
there's only a few code paths for doing that.

Also an adjustment is needed in the import system - this introduces a
circular relation between Recipient and UserProfile. The field cannot be
set until the Recipient objects have been created, but UserProfiles need
to be created before their corresponding Recipients. We deal with this
by first importing UserProfiles same way as before, but we leave the
personal_recipient field uninitialized. After creating the Recipient
objects, we call a function to set the field for all the imported users
in bulk.

A similar change is made for managing Stream objects.
2019-12-09 15:14:41 -08:00
..
__init__.py Move management commands to the analytics app. 2013-11-06 16:51:08 -05:00
analyze_mit.py models: Migration of Message.pub_date to date_sent, part 2. 2019-10-05 19:01:34 -07:00
analyze_user_activity.py analytics: Use python 3 syntax for typing. 2017-11-17 13:16:49 -08:00
check_analytics_state.py analytics/zilencer/zproject: Remove unused imports. 2019-02-02 17:31:45 -08:00
clear_analytics_tables.py management: Don't use sys.exit(1). 2019-05-03 14:20:39 -07:00
clear_single_stat.py management: Don't use sys.exit(1). 2019-05-03 14:20:39 -07:00
client_activity.py typing: Fix options typing in management/commands. 2019-07-31 12:13:56 -07:00
populate_analytics_db.py models: Add recipient foreign key in UserProfile and Stream. 2019-12-09 15:14:41 -08:00
realm_stats.py models: Migration of Message.pub_date to date_sent, part 2. 2019-10-05 19:01:34 -07:00
stream_stats.py management: Don't use sys.exit(1). 2019-05-03 14:20:39 -07:00
update_analytics_counts.py production: Add optional support for submitting usage statistics. 2019-02-26 17:35:10 -08:00
user_stats.py models: Migration of Message.pub_date to date_sent, part 2. 2019-10-05 19:01:34 -07:00