Преглед изворни кода

[indexer] Setup examples in search API

Abraham Elmahrek пре 11 година
родитељ
комит
d9cb9fc

+ 0 - 6
apps/about/src/about/templates/admin_wizard.mako

@@ -114,12 +114,6 @@ ${ header.menubar() }
                   <i class="fa fa-download"></i> ${ apps['search'].nice_name }
                 </a>
               </li>
-              <li>
-                <a href="#" class="installBtn" data-loading-text="${ _('Installing...') }"
-                   data-sample-url="${ url('indexer:install_examples') }">
-                  <i class="fa fa-download"></i> ${ apps['indexer'].nice_name }
-                </a>
-              </li>
           % endif
           % if 'oozie' in app_names:
               <li>

+ 3 - 0
apps/search/src/search/views.py

@@ -36,6 +36,8 @@ from search.management.commands import search_setup
 from search.models import Collection, augment_solr_response, augment_solr_exception
 from search.search_controller import SearchController
 
+from indexer.management.commands import indexer_setup
+
 from django.utils.encoding import force_unicode
 from desktop.lib.rest.http_client import RestException
 
@@ -528,6 +530,7 @@ def install_examples(request):
   else:
     try:
       search_setup.Command().handle_noargs()
+      indexer_setup.Command().handle_noargs()
       result['status'] = 0
     except Exception, e:
       LOG.exception(e)

+ 2 - 1
desktop/libs/indexer/src/indexer/management/commands/indexer_install_examples.py → desktop/libs/indexer/src/indexer/management/commands/indexer_setup.py

@@ -15,6 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import itertools
 import logging
 import uuid
 import os
@@ -119,5 +120,5 @@ class Command(NoArgsCommand):
       field_generator = utils.field_values_from_separated_file(fh, separator, quote_character)
       row = next(field_generator)
       field_names = row.keys()
-      field_types = utils.get_field_types(row.values())
+      field_types = utils.get_field_types((row.values() for row in itertools.chain([row], field_generator)), iterations=51)
       return [{'name': field[0], 'type': field[0] in fieldtypes and fieldtypes[field[0]] or field[1]} for field in zip(field_names, field_types)]

+ 2 - 2
desktop/libs/indexer/src/indexer/views.py

@@ -23,7 +23,7 @@ from django.utils.translation import ugettext as _
 
 from desktop.lib.django_util import render
 
-from indexer.management.commands import indexer_install_examples
+from indexer.management.commands import indexer_setup
 
 
 LOG = logging.getLogger(__name__)
@@ -39,7 +39,7 @@ def install_examples(request, is_redirect=False):
     result['message'] = _('A POST request is required.')
   else:
     try:
-      indexer_install_examples.Command().handle_noargs()
+      indexer_setup.Command().handle_noargs()
       result['status'] = 0
     except Exception, e:
       LOG.exception(e)