def delete_expired_urls(): dry_run = '--dry-run' in sys.argv now = datetime.utcnow().replace(tzinfo=timezone.utc) print('I am going to delete the urls that expire before {}'.format( str(now))) es_connection.setup_glados_es_connection(DATA_CONNECTION) es_conn = connections.get_connection(alias=DATA_CONNECTION) query = { "query": { "range": { "expires": { "lte": str(int(now.timestamp() * 1000)) } } }, 'track_total_hits': True } total_items = es_conn.search(index=ES_INDEX, body=query)['hits']['total']['value'] if dry_run: print('I would have deleted {} saved urls (dry run).'.format( total_items)) else: bulk(es_conn, stream_items(es_conn, query), chunk_size=BULK_SIZE) print('Deleted {} expired shortened urls.'.format(total_items))
def print_properties_counts(): setup_glados_es_connection(connection_type=DATA_CONNECTION) setup_glados_es_connection(connection_type=MONITORING_CONNECTION) print() print_groups_counts() print() print_props_counts()
from . import views from django.contrib import admin import glados.grammar.search_parser from django.views.i18n import JavaScriptCatalog from glados import old_urls_redirector from django.conf.urls import url from django.http import HttpResponse from django.views.decorators.cache import cache_page from django.urls import path from django.views.generic.base import RedirectView from glados.es_connection import setup_glados_es_connection, DATA_CONNECTION, MONITORING_CONNECTION # Setup Elastic Search Connection here only once setup_glados_es_connection(DATA_CONNECTION) setup_glados_es_connection(MONITORING_CONNECTION) common_urls = [ # -------------------------------------------------------------------------------------------------------------------- # Translation for Javascript # -------------------------------------------------------------------------------------------------------------------- path('glados_jsi18n/glados', cache_page(86400, key_prefix='glados_jsi18n1')( JavaScriptCatalog.as_view(packages=['glados'], domain='glados')), name='js-glados-catalog'), path('glados_jsi18n/glados_es_generated', cache_page(86400, key_prefix='glados_es_generated1')( JavaScriptCatalog.as_view(packages=['glados'], domain='glados_es_generated')), name='js-glados_es_generated-catalog'),
def setUp(self): DownloadJob.objects.all().delete() setup_glados_es_connection(connection_type=DATA_CONNECTION) setup_glados_es_connection(connection_type=MONITORING_CONNECTION)
def setUp(self): self.request_factory = RequestFactory() setup_glados_es_connection(connection_type=DATA_CONNECTION) setup_glados_es_connection(connection_type=MONITORING_CONNECTION)
def setUp(self): setup_glados_es_connection(connection_type=DATA_CONNECTION) setup_glados_es_connection(connection_type=MONITORING_CONNECTION)