def search_suggestions(request): from digipal.utils import get_json_response from content_type.search_content_type import SearchContentType query = request.GET.get('q', '') try: limit = int(request.GET.get('l')) except: limit = 8 suggestions = SearchContentType().get_suggestions(query, limit) return get_json_response(suggestions)
def patterns_api_view(request, root, path): ana = PatternAnalyser() data = ana.process_request_api(request, root, path) format = data.get('format', 'json') if format in ['csv']: now = datetime.now() file_name = 'segments-%s-%s-%s.csv' % (now.day, now.month, now.year) ret = dputils.get_csv_response_from_rows(data['csv'], headings=['unitid', 'pattern_group', 'pattern_key', 'segment', 'variant'], filename=file_name) else: ret = dputils.get_json_response(data) return ret
def patterns_api_view(request, root, path): ana = PatternAnalyser() data = ana.process_request_api(request, root, path) format = data.get('format', 'json') if format in ['csv']: now = datetime.now() file_name = 'segments-%s-%s-%s.csv' % (now.day, now.month, now.year) ret = dputils.get_csv_response_from_rows(data['csv'], headings=[ 'unitid', 'pattern_group', 'pattern_key', 'segment', 'variant' ], filename=file_name) else: ret = dputils.get_json_response(data) return ret