def send_saved_search_alerts(): from pmg import app from pmg.models import SavedSearch application = newrelic.agent.application() with newrelic.agent.BackgroundTask(application, name='send_saved_search_alerts', group='Task'): with app.app_context(): SavedSearch.send_all_alerts()
def sync_soundcloud(): from pmg import app from pmg.models.soundcloud_track import SoundcloudTrack application = newrelic.agent.application() with newrelic.agent.BackgroundTask(application, name='sync_soundcloud', group='Task'): with app.app_context(): SoundcloudTrack.sync()
def test_new_object_reindexed(self, bulk_index): with app.app_context(): cm = CommitteeMeeting() cm.date = arrow.now().datetime cm.title = "Foo" db.session.add(cm) db.session.commit() assert_true(bulk_index.called)
def test_deleted_object_reindexed(self, delete, bulk_index): with app.app_context(): cm = CommitteeMeeting() cm.date = arrow.now().datetime cm.title = "Foo" db.session.add(cm) db.session.commit() assert_true(bulk_index.called) bulk_index.reset_mock() # now delete it db.session.delete(cm) db.session.commit() assert_false(bulk_index.called) assert_true(delete.called)
#!/bin/env python import argparse import os import sys sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../')) from pmg.search import Search, Transforms from pmg import app if __name__ == "__main__": data_types = Transforms.data_types() + ['all'] parser = argparse.ArgumentParser(description='ElasticSearch PMG library') parser.add_argument('data_type', metavar='DATA_TYPE', choices=data_types, help='Data type to manipulate: %s' % data_types) parser.add_argument('--reindex', action="store_true") parser.add_argument('--delete', action="store_true") args = parser.parse_args() search = Search() if args.reindex: with app.app_context(): if args.data_type == 'all': search.reindex_everything() else: search.reindex_all(args.data_type) if args.delete: search.delete_everything()
def send_saved_search_alerts(): from pmg import app from pmg.models import SavedSearch with app.app_context(): SavedSearch.send_all_alerts()
def sync_soundcloud(): from pmg import app from pmg.models.soundcloud_track import SoundcloudTrack with app.app_context(): SoundcloudTrack.sync()
def update_active_committees(): from pmg import app from pmg.models import Committee with app.app_context(): Committee.update_active_committees()