Browse Source

HUE-6657 [editor] Ignore history queries when checking for existing sample queries

Jenny Kim 8 years ago
parent
commit
e8f34501e1

+ 1 - 1
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -322,7 +322,7 @@ class SampleQuery(object):
 
       try:
         # Don't overwrite
-        doc2 = Document2.objects.get(owner=django_user, name=self.name, type=self._document_type(self.type))
+        doc2 = Document2.objects.get(owner=django_user, name=self.name, type=self._document_type(self.type), is_history=False)
         # If document exists but has been trashed, recover from Trash
         if doc2.parent_directory != examples_dir:
           doc2.parent_directory = examples_dir

+ 8 - 8
apps/oozie/src/oozie/management/commands/oozie_setup.py

@@ -114,9 +114,9 @@ class Command(NoArgsCommand):
     doc2 = None
     name = _('MapReduce Sleep Job')
 
-    if Document2.objects.filter(owner=self.user, name=name, type='query-mapreduce').exists():
+    if Document2.objects.filter(owner=self.user, name=name, type='query-mapreduce', is_history=False).exists():
       LOG.info("Sample mapreduce editor job already installed.")
-      doc2 = Document2.objects.get(owner=self.user, name=name, type='query-mapreduce')
+      doc2 = Document2.objects.get(owner=self.user, name=name, type='query-mapreduce', is_history=False)
     else:
       snippet_properties = {
         'app_jar': '/user/hue/oozie/workspaces/lib/hadoop-examples.jar',
@@ -169,9 +169,9 @@ class Command(NoArgsCommand):
     doc2 = None
     name = _('Java Terasort Job')
 
-    if Document2.objects.filter(owner=self.user, name=name, type='query-java').exists():
+    if Document2.objects.filter(owner=self.user, name=name, type='query-java', is_history=False).exists():
       LOG.info("Sample Java editor job already installed.")
-      doc2 = Document2.objects.get(owner=self.user, name=name, type='query-java')
+      doc2 = Document2.objects.get(owner=self.user, name=name, type='query-java', is_history=False)
     else:
       snippet_properties = {
         'app_jar': '/user/hue/oozie/workspaces/lib/hadoop-examples.jar',
@@ -221,9 +221,9 @@ class Command(NoArgsCommand):
     doc2 = None
     name = _('Spark File Copy Job')
 
-    if Document2.objects.filter(owner=self.user, name=name, type='query-spark2').exists():
+    if Document2.objects.filter(owner=self.user, name=name, type='query-spark2', is_history=False).exists():
       LOG.info("Sample Spark editor job already installed.")
-      doc2 = Document2.objects.get(owner=self.user, name=name, type='query-spark2')
+      doc2 = Document2.objects.get(owner=self.user, name=name, type='query-spark2', is_history=False)
     else:
       snippet_properties = {
         'jars': ['/user/hue/oozie/workspaces/workflows/spark-scala/lib/oozie-examples.jar'],
@@ -275,9 +275,9 @@ class Command(NoArgsCommand):
     doc2 = None
     name = _('PySpark Pi Estimator Job')
 
-    if Document2.objects.filter(owner=self.user, name=name, type='query-spark2').exists():
+    if Document2.objects.filter(owner=self.user, name=name, type='query-spark2', is_history=False).exists():
       LOG.info("Sample pyspark editor job already installed.")
-      doc2 = Document2.objects.get(owner=self.user, name=name, type='query-spark2')
+      doc2 = Document2.objects.get(owner=self.user, name=name, type='query-spark2', is_history=False)
     else:
       snippet_properties = {
         'jars': ['/user/hue/oozie/workspaces/lib/pi.py'],

+ 2 - 2
apps/pig/src/pig/management/commands/pig_setup.py

@@ -45,9 +45,9 @@ class Command(NoArgsCommand):
     doc2 = None
     name = _('UpperText')
 
-    if Document2.objects.filter(owner=sample_user, name=name, type='query-pig').exists():
+    if Document2.objects.filter(owner=sample_user, name=name, type='query-pig', is_history=False).exists():
       LOG.info("Sample pig editor script already installed.")
-      doc2 = Document2.objects.get(owner=sample_user, name=name, type='query-pig')
+      doc2 = Document2.objects.get(owner=sample_user, name=name, type='query-pig', is_history=False)
     else:
       statement = """data = LOAD '/user/hue/pig/examples/data/midsummer.txt' as (text:CHARARRAY);