def cleanup_index(self, index): self.logger.debug("Cleanup index %s" % index.name) Log = create_index_model(index) for column in index.loggercolumn_set.filter(filtered=True): first_day = index.index_dates[0] ts = time.mktime(first_day.timetuple()) self.cleanup_column(Log, column, ts)
def log_model(self): start_ts = self.request.GET.get('start_ts') or '' try: f = DateTimeField() distr = f.to_internal_value(start_ts).strftime('%Y%m%d') except Exception: distr = None return create_index_model(self.index, distr=distr)
def get_context_data(self, **kwargs): cd = super(IndexListView, self).get_context_data(**kwargs) ts = datetime.now().replace(microsecond=0) - timedelta(minutes=5) distr = ts.strftime('%Y%m%d') for index in cd['object_list']: log_model = create_index_model(index, distr=distr) start_id = int(time.mktime(ts.timetuple()) * 1000000000) index.last_count = log_model.objects.filter(id__gt=start_id).count() return cd
def log_model(self): start_ts = self.request.GET.get("start_ts") or "" try: f = DateTimeField() distr = f.to_internal_value(start_ts).strftime("%Y%m%d") except Exception: distr = None return create_index_model(self.index, distr=distr)
def get_context_data(self, **kwargs): cd = super(IndexListView, self).get_context_data(**kwargs) ts = datetime.now().replace(microsecond=0) - timedelta(minutes=5) distr = ts.strftime('%Y%m%d') for index in cd['object_list']: log_model = create_index_model(index, distr=distr) start_id = int(time.mktime(ts.timetuple()) * 1000000000) index.last_count = log_model.objects.filter( id__gt=start_id).count() return cd