declarations.com.ua icon indicating copy to clipboard operation
declarations.com.ua copied to clipboard

Fix import from vulyk: empty dicts

Open dchaplinsky opened this issue 10 years ago • 3 comments

Because of conversion document->table->document, some of documents now has totally empty dicts.

Please address that problem.

dchaplinsky avatar Jul 20 '15 23:07 dchaplinsky

$ ./manage.py analytics
Traceback (most recent call last):
  File "/var/www/declarations.com.ua/env/lib/python3.4/site-packages/elasticsearch_dsl/utils.py", line 102, in __getattr__
    return _wrap(self._d_[attr_name])
KeyError: 'addresses'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/var/www/declarations.com.ua/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/var/www/declarations.com.ua/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/www/declarations.com.ua/env/lib/python3.4/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/var/www/declarations.com.ua/env/lib/python3.4/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/var/www/declarations.com.ua/site/declarations_site/catalog/management/commands/analytics.py", line 36, in handle
    table = self._generate_table(all_decls)
  File "/var/www/declarations.com.ua/site/declarations_site/catalog/management/commands/analytics.py", line 59, in _generate_table
    decl_dict = self._map_fields(decl)
  File "/var/www/declarations.com.ua/site/declarations_site/catalog/management/commands/analytics.py", line 102, in _map_fields
    'region': declaration.general.addresses[0].place,
  File "/var/www/declarations.com.ua/env/lib/python3.4/site-packages/elasticsearch_dsl/utils.py", line 397, in __getattr__
    return super(ObjectBase, self).__getattr__(name)
  File "/var/www/declarations.com.ua/env/lib/python3.4/site-packages/elasticsearch_dsl/utils.py", line 105, in __getattr__
    '%r object has no attribute %r' % (self.__class__.__name__, attr_name))
AttributeError: 'InnerObjectWrapper' object has no attribute 'addresses'

dchaplinsky avatar Jan 02 '16 22:01 dchaplinsky

Not completely sure if that's related as it doesn't seem (and not supposed) to remove elements that contain a list, only list elements. Both cases (import and script) assign at least an empty list to the list-containing element as long as it was actually present in the source. Were there any files imported after the last successful analytics generation event?

In any case, I'll test this locally.

excieve avatar Jan 02 '16 23:01 excieve

Were there any files imported after the last successful analytics generation event? Not to my memory.

dchaplinsky avatar Jan 03 '16 00:01 dchaplinsky