I modified the oq-platform so this code isn't required anymore. See https://github.com/gem/oq-platform/pull/156