export: Remove stream sanity check.

We also remove the post_process_data option.

The sanity check is just overkill at this point,
since the mechanism to find streams is very
direct due to a recent commit.
This commit is contained in:
Steve Howell 2020-07-09 13:20:02 +00:00 committed by Tim Abbott
parent 54c596cfc4
commit 9662af842f
1 changed files with 0 additions and 34 deletions

View File

@ -394,7 +394,6 @@ class Config:
filter_args: Optional[FilterArgs]=None,
custom_fetch: Optional[CustomFetch]=None,
custom_tables: Optional[List[TableName]]=None,
post_process_data: Optional[PostProcessData]=None,
concat_and_destroy: Optional[List[TableName]]=None,
id_source: Optional[IdSource]=None,
source_filter: Optional[SourceFilter]=None,
@ -414,7 +413,6 @@ class Config:
self.exclude = exclude
self.custom_fetch = custom_fetch
self.custom_tables = custom_tables
self.post_process_data = post_process_data
self.concat_and_destroy = concat_and_destroy
self.id_source = id_source
self.source_filter = source_filter
@ -552,13 +550,6 @@ def export_from_config(response: TableData, config: Config, seed_object: Optiona
if table in DATE_FIELDS:
floatify_datetime_fields(response, table)
if config.post_process_data:
config.post_process_data(
response=response,
config=config,
context=context,
)
# Now walk our children. It's extremely important to respect
# the order of children here.
for child_config in config.children:
@ -746,7 +737,6 @@ def get_realm_config() -> Config:
table='zerver_stream',
model=Stream,
exclude=['email_token'],
post_process_data=sanity_check_stream_data,
normal_parent=realm_config,
parent_key='realm_id__in',
)
@ -801,30 +791,6 @@ def get_realm_config() -> Config:
return realm_config
def sanity_check_stream_data(response: TableData, config: Config, context: Context) -> None:
if context['exportable_user_ids'] is not None:
# If we restrict which user ids are exportable,
# the way that we find # streams is a little too
# complex to have a sanity check.
return
actual_streams = {stream.name for stream in Stream.objects.filter(
realm=response["zerver_realm"][0]['id'])}
streams_in_response = {stream['name'] for stream in response['zerver_stream']}
if len(streams_in_response - actual_streams) > 0:
print("Error: Streams not present in the realm were exported:")
print(" ", streams_in_response - actual_streams)
print("This is likely due to a bug in the export tool.")
raise AssertionError("Aborting! Please investigate.")
if len(actual_streams - streams_in_response) > 0:
print("Error: Some streams present in the realm were not exported:")
print(" ", actual_streams - streams_in_response)
print("Usually, this is caused by a stream having been created that never had subscribers.")
print("(Due to a bug elsewhere in Zulip, not in the export tool)")
raise AssertionError("Aborting! Please investigate.")
def fetch_user_profile(response: TableData, config: Config, context: Context) -> None:
realm = context['realm']
exportable_user_ids = context['exportable_user_ids']