示例#1
0
    def build_indices(self):
        if self.dry_run or not self.do_build_indices:
            return False

        log.info("Building search indices")
        solr.drop_index(self.model['dataset']['name'])
        solr.build_index(self.model['dataset']['name'])
示例#2
0
 def delete(self, dataset):
     self._get_dataset(dataset)
     require.dataset.delete(c.dataset)
     c.dataset.drop()
     solr.drop_index(c.dataset.name)
     db.session.delete(c.dataset)
     db.session.commit()
     h.flash_success(_("The dataset has been deleted."))
     redirect(h.url_for(controller='dataset', action='index'))
示例#3
0
 def delete(self, dataset):
     self._get_dataset(dataset)
     require.dataset.delete(c.dataset)
     c.dataset.drop()
     solr.drop_index(c.dataset.name)
     db.session.delete(c.dataset)
     db.session.commit()
     h.flash_success(_("The dataset has been deleted."))
     redirect(h.url_for(controller='dataset', action='index'))
示例#4
0
 def drop(self, dataset):
     self._get_dataset(dataset)
     require.dataset.update(c.dataset)
     c.dataset.drop()
     solr.drop_index(c.dataset.name)
     c.dataset.init()
     c.dataset.generate()
     AggregationCache(c.dataset).invalidate()
     db.session.commit()
     h.flash_success(_("The dataset has been cleared."))
     redirect(h.url_for(controller='editor', action='index', 
                        dataset=c.dataset.name))
示例#5
0
 def drop(self, dataset):
     self._get_dataset(dataset)
     require.dataset.update(c.dataset)
     c.dataset.updated_at = datetime.utcnow()
     c.dataset.drop()
     solr.drop_index(c.dataset.name)
     c.dataset.init()
     c.dataset.generate()
     AggregationCache(c.dataset).invalidate()
     db.session.commit()
     h.flash_success(_("The dataset has been cleared."))
     redirect(
         h.url_for(controller='editor',
                   action='index',
                   dataset=c.dataset.name))
示例#6
0
    def drop(self, dataset):
        self._get_dataset(dataset)
        require.dataset.update(c.dataset)
        c.dataset.updated_at = datetime.utcnow()
        c.dataset.drop()
        solr.drop_index(c.dataset.name)
        c.dataset.init()
        c.dataset.generate()
        AggregationCache(c.dataset).invalidate()

        # For every source in the dataset we set the status to removed
        for source in c.dataset.sources:            
            for run in source.runs:
                run.status = Run.STATUS_REMOVED

        db.session.commit()
        h.flash_success(_("The dataset has been cleared."))
        redirect(h.url_for(controller='editor', action='index',
                           dataset=c.dataset.name))
示例#7
0
    def drop(self, dataset):
        self._get_dataset(dataset)
        require.dataset.update(c.dataset)
        c.dataset.updated_at = datetime.utcnow()
        c.dataset.drop()
        solr.drop_index(c.dataset.name)
        c.dataset.init()
        c.dataset.generate()
        AggregationCache(c.dataset).invalidate()

        # For every source in the dataset we set the status to removed
        for source in c.dataset.sources:
            for run in source.runs:
                run.status = Run.STATUS_REMOVED

        db.session.commit()
        h.flash_success(_("The dataset has been cleared."))
        redirect(h.url_for(controller='editor', action='index',
                           dataset=c.dataset.name))
示例#8
0
    def command(self):
        super(SolrCommand, self).command()

        if len(self.args) < 1:
            SolrCommand.parser.print_help()
            return 1

        cmd = self.args[0]

        from openspending.lib import solr_util as solr

        if cmd == 'load':
            solr.build_index(self.args[1])
        elif cmd == 'delete':
            solr.drop_index(self.args[1])
        elif cmd == 'optimize':
            solr.optimize()
        elif cmd == 'clean':
            s = solr.get_connection()
            s.delete_query('*:*')
            s.commit()
        else:
            raise self.BadCommand("Subcommand '%s' not recognized " \
                                  "by 'solr' command!" % cmd)
示例#9
0
def delete(dataset):
    solr.drop_index(dataset)
    return 0
示例#10
0
def delete(dataset):
    solr.drop_index(dataset)
    return 0
示例#11
0
 def test_drop_index(self):
     solr.drop_index('foo')
     self.mock_solr.return_value.delete_query.assert_called_once_with('dataset:foo')
     self.mock_solr.return_value.commit.assert_called_once()
示例#12
0
 def test_drop_index(self):
     solr.drop_index('foo')
     self.mock_solr.return_value.delete_query.assert_called_once_with(
         'dataset:foo')
     self.mock_solr.return_value.commit.assert_called_once()