[core] Converter should separate history docs from saved docs
@@ -57,9 +57,6 @@ class DocumentConverter(object):
notebook = import_saved_beeswax_query(doc.content_object)
data = notebook.get_data()
- if doc.is_historic():
- data['isSaved'] = False
-
doc2 = self._create_doc2(
document=doc,
doctype=data['type'],
@@ -68,9 +65,6 @@ class DocumentConverter(object):
data=notebook.get_json()
)
- if doc.is_historic():
- doc2.is_history = False
-
self.imported_docs.append(doc2)
except Exception, e:
self.failed_docs.append(doc)
@@ -82,7 +76,7 @@ class DocumentConverter(object):
try:
from beeswax.models import SavedQuery, HQL, IMPALA, RDBMS
- docs = self._get_unconverted_docs(SavedQuery, with_history=True).filter(extra__in=[HQL, IMPALA, RDBMS]).order_by('-last_modified')
+ docs = self._get_unconverted_docs(SavedQuery, only_history=True).filter(extra__in=[HQL, IMPALA, RDBMS]).order_by('-last_modified')
for doc in docs:
try:
@@ -192,7 +186,7 @@ class DocumentConverter(object):
LOG.exception("Failed to set is_trashed field with exception: %s" % e)
- def _get_unconverted_docs(self, content_type, with_history=False):
+ def _get_unconverted_docs(self, content_type, only_history=False):
docs = Document.objects.get_docs(self.user, content_type).filter(owner=self.user)
tags = [
@@ -201,8 +195,10 @@ class DocumentConverter(object):
self.imported_tag # No already imported docs
]
- if not with_history:
- tags.append(DocumentTag.objects.get_history_tag(user=self.user)) # No history yet
+ if only_history:
+ docs = docs.filter(tags__in=[DocumentTag.objects.get_history_tag(user=self.user)])
+ else: # Exclude history docs by default
+ tags.append(DocumentTag.objects.get_history_tag(user=self.user))
return docs.exclude(tags__in=tags)
