Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user exports: Add several tables to the tarball.
Steve Howell946e8064a31c
diff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex bcf25b887b2..5a445b585cf 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -689,13 +689,6 @@ def get_realm_config() -> Config:custom_fetch=fetch_user_profile,)- Config(- table="zerver_alertword",- model=AlertWord,- normal_parent=user_profile_config,- parent_key="user_profile__in",- )-user_groups_config = Config(table="zerver_usergroup",model=UserGroup,@@ -725,55 +718,6 @@ def get_realm_config() -> Config:custom_fetch=fetch_user_profile_cross_realm,)- Config(- table="zerver_userpresence",- model=UserPresence,- normal_parent=user_profile_config,- parent_key="user_profile__in",- )-- Config(- table="zerver_customprofilefieldvalue",- model=CustomProfileFieldValue,- normal_parent=user_profile_config,- parent_key="user_profile__in",- )-- Config(- table="zerver_useractivity",- model=UserActivity,- normal_parent=user_profile_config,- parent_key="user_profile__in",- )-- Config(- table="zerver_useractivityinterval",- model=UserActivityInterval,- normal_parent=user_profile_config,- parent_key="user_profile__in",- )-- Config(- table="zerver_realmauditlog",- model=RealmAuditLog,- normal_parent=user_profile_config,- parent_key="modified_user__in",- )-- Config(- table="zerver_userhotspot",- model=UserHotspot,- normal_parent=user_profile_config,- parent_key="user__in",- )-- Config(- table="zerver_usertopic",- model=UserTopic,- normal_parent=user_profile_config,- parent_key="user_profile__in",- )-Config(table="zerver_service",model=Service,@@ -871,9 +815,83 @@ def get_realm_config() -> Config:],)+ add_user_profile_child_configs(user_profile_config)+return realm_config+def add_user_profile_child_configs(user_profile_config: Config) -> None:+ """+ We add tables here that are keyed by user, and for which+ we fetch rows using the same scheme whether we are+ exporting a realm or a single user.++ For any table where there is nuance between how you+ fetch for realms vs. single users, it's best to just+ keep things simple and have each caller maintain its+ own slightly different 4/5 line Config (while still+ possibly calling common code deeper in the stack).++ As of now, we do NOT include bot tables like Service.+ """++ Config(+ table="zerver_useractivity",+ model=UserActivity,+ normal_parent=user_profile_config,+ parent_key="user_profile__in",+ )++ Config(+ table="zerver_useractivityinterval",+ model=UserActivityInterval,+ normal_parent=user_profile_config,+ parent_key="user_profile__in",+ )++ Config(+ table="zerver_alertword",+ model=AlertWord,+ normal_parent=user_profile_config,+ parent_key="user_profile__in",+ )++ Config(+ table="zerver_customprofilefieldvalue",+ model=CustomProfileFieldValue,+ normal_parent=user_profile_config,+ parent_key="user_profile__in",+ )++ Config(+ table="zerver_realmauditlog",+ model=RealmAuditLog,+ normal_parent=user_profile_config,+ parent_key="modified_user__in",+ )++ Config(+ table="zerver_userhotspot",+ model=UserHotspot,+ normal_parent=user_profile_config,+ parent_key="user__in",+ )++ Config(+ table="zerver_userpresence",+ model=UserPresence,+ normal_parent=user_profile_config,+ parent_key="user_profile__in",+ )++ Config(+ table="zerver_usertopic",+ model=UserTopic,+ normal_parent=user_profile_config,+ parent_key="user_profile__in",+ )++def fetch_user_profile(response: TableData, config: Config, context: Context) -> None:realm = context["realm"]exportable_user_ids = context["exportable_user_ids"]@@ -1835,6 +1853,15 @@ def get_single_user_config() -> Config:exclude=["email_token"],)+ Config(+ table="analytics_usercount",+ model=UserCount,+ normal_parent=user_profile_config,+ parent_key="user__in",+ )++ add_user_profile_child_configs(user_profile_config)+return user_profile_config