@csrf_exempt
def popular_users_get(request):
    print('popular_users_get')
    users_list = []
    if (request.method == 'POST'):
        (twitter_users, tweets) = generate_users_tweets(request, tasdocs=True, uasdocs=True)
        if isinstance(twitter_users, Exception):
            return JsonResponse(str(twitter_users), safe=False, status=500)
        elif (len(twitter_users) == 0):
            return JsonResponse('Error: No Tweets in location / date / search phrase (if included)', safe=False, status=500)
        slider_valus = slider_val_transform(jsonpickle.decode(request.POST.get('sliders_data', None)))
        print(len(twitter_users))
        print(len(tweets))
        queriesManager = QueriesManager()
        params = ['Opinion_Leaders', [str(slider_valus[0][1])], [str(slider_valus[0][0])], [str(slider_valus[3][1])], [str(slider_valus[3][0])], [str(slider_valus[2][1])], [str(slider_valus[2][0])], [str(slider_valus[1][1])], [str(slider_valus[1][0])]]
        print(params)
        print(twitter_users[0].keys())
        df = queriesManager.call_querie(params, tweets, twitter_users)
        print(df)
        if df.empty:
            return JsonResponse('Error: No opinion leaders found', safe=False)
        idlist = df['id'].tolist()
        print(len(idlist))
        users_list = get_from_db(idlist, twitter_users_database_name, UserExtension)
        print(len(users_list))
    user_ext_list = user_ext_to_json(users_list)
    return JsonResponse(user_ext_list, safe=False)
@csrf_exempt
def popular_users_get(request):
    print('popular_users_get')
    users_list = []
    if (request.method == 'POST'):
        (twitter_users, tweets) = generate_users_tweets(request, tasdocs=True, uasdocs=True)
        if isinstance(twitter_users, Exception):
            return JsonResponse(str(twitter_users), safe=False, status=500)
        elif (len(twitter_users) == 0):
            return JsonResponse('Error: No Tweets in location / date / search phrase (if included)', safe=False, status=500)
        slider_valus = slider_val_transform(jsonpickle.decode(request.POST.get('sliders_data', None)))
        print(len(twitter_users))
        print(len(tweets))
        queriesManager = QueriesManager()
        params = ['Opinion_Leaders', [str(slider_valus[0][1])], [str(slider_valus[0][0])], [str(slider_valus[3][1])], [str(slider_valus[3][0])], [str(slider_valus[2][1])], [str(slider_valus[2][0])], [str(slider_valus[1][1])], [str(slider_valus[1][0])]]
        print(params)
        print(twitter_users[0].keys())
        df = queriesManager.call_querie(params, tweets, twitter_users)
        print(df)
        if df.empty:
            return JsonResponse('Error: No opinion leaders found', safe=False)
        idlist = df['id'].tolist()
        print(len(idlist))
        users_list = get_from_db(idlist, twitter_users_database_name, UserExtension)
        print(len(users_list))
    user_ext_list = user_ext_to_json(users_list)
    return JsonResponse(user_ext_list, safe=False)