def get_reco_list_dpp(request, category): reco_list_dpp = [] data = get_reco_algo(request.user, 'knn', category) works = data['works'] for work_id in data['work_ids']: work = works[work_id] reco_list_dpp.append({'id': work.id, 'title': work.title, 'poster': work.ext_poster, 'synopsis': work.synopsis, 'category': work.category.slug}) return HttpResponse(json.dumps(reco_list_dpp), content_type='application/json')
def get_reco_algo_list(request, algo_name, category): reco_list = [] data = get_reco_algo(request, algo_name, category) works = data['works'] categories = dict(WORK_CATEGORY_CHOICES) for work_id in data['work_ids']: work = works[work_id] reco_list.append({'id': work.id, 'title': work.title, 'poster': work.ext_poster, 'synopsis': work.synopsis, 'category_slug': work.category.slug, 'category': str(categories[work.category.slug])}) return HttpResponse(json.dumps(reco_list), content_type='application/json')