def results(): title = request.form['title_input'] content = request.form['content_input'] end_time = request.form['time2'] start_time = request.form['time1'] type_news = request.form.get('news_filter') print(title, content, end_time, start_time, type_news) pre_res = es.search(index='ctt_hust', body={ "query": { "bool": { "must": [{ "match_phrase": { "content": { "query": content } } }, { "match_phrase": { "title": { "query": title } } }] } } }) res = [] if len(pre_res['hits']['hits']) > 0: for result_ in pre_res['hits']['hits']: result = result_ day = result['_source']['time'] print(result['_source']['type_lv2']) if start_time != '': time_check1 = utils.compare_time(day, start_time) else: time_check1 = True if end_time != '': time_check2 = utils.compare_time(end_time, day) else: time_check2 = True if type_news != '': type_check = result['_source']['type_lv2'] == type_news else: type_check = True if time_check1 and time_check2 and type_check: res.append(result_) pre_res['hits']['hits'] = res pre_res['hits']['total'] = str(len(res)) page = render_template('advance_search_results.html', res=pre_res) print(pre_res) return page
def isTimeReconnect(self): """Checks if pyload will try to make a reconnect :return: bool """ start = self.core.config['reconnect']['startTime'].split(":") end = self.core.config['reconnect']['endTime'].split(":") return compare_time(start, end) and self.core.config["reconnect"]["activated"]
def isTimeDownload(self): """Checks if pyload will start new downloads according to time in config. :return: bool """ start = self.core.config['downloadTime']['start'].split(":") end = self.core.config['downloadTime']['end'].split(":") return compare_time(start, end)
def time_divide(flavor_count_day_sum,time_start,time_end): ''' count from time_start to time_end :param flavor_count_day_sum: :param time_start: :param time_end: :return: ''' flavor_day_dict = {} for i,flavor_sum in enumerate(flavor_count_day_sum): for element in flavor_sum: if compare_time(element.split('_')[1], time_start, time_end): flavor = 'flavor%s' % str(i) flavor_day_dict.setdefault(flavor, 0) flavor_day_dict[flavor] += 1 return flavor_day_dict