def post(request): print('yes') if is_url_out(request.data, 'url'): return JsonResponse( { 'Response': 'Database parameter URL in request data not found.' }, status=400) date_from = datetime.datetime.strptime(request.data['date_from'], '%d.%m.%Y').date() date_to = datetime.datetime.strptime(request.data['date_to'], '%d.%m.%Y').date() database_url = request.data['url'] statistics = Statistics(database_url) if statistics: return JsonResponse( { 'statistics': statistics.get_statistics_by_point_between_dates( request.data['point'], date_from, date_to) }, status=200)
def delete(request): if is_url_out(request.data, 'url'): return JsonResponse( { 'Response': 'Database parameter URL in request data not found.' }, status=400) database_url = request.data['url'] statistics = Statistics(database_url) if statistics: statistics.clear_statistics() return JsonResponse( { 'Response': 'Table \'statistic\' has been cleared in database.' }, status=200) else: return JsonResponse( { 'Response': 'UserPosition application creation has been failed.' }, status=400)
def post(request): if is_url_out(request.data, 'url'): return JsonResponse( { 'Response': 'Database parameter URL in request data not found.' }, status=400) database_url = request.data['url'] statistics = Statistics(database_url) if statistics: statistics.create_statistics() return JsonResponse( { 'Response': 'Statistic application was successfully initialized.', 'Done': 'Table \'statistic\' has been created in database.', 'Additional documentation information': 'If table already exists, requests does not re-create it.' }, status=200) else: return JsonResponse( { 'Response': 'Statistic application creation has been failed.' }, status=400)
def post(request): if is_url_out(request.data, 'url'): return JsonResponse( { 'Response': 'Database parameter URL in request data not found.' }, status=400) database_url = request.data['url'] statistics = Statistics(database_url) if statistics: return JsonResponse( {'statistics': statistics.get_statistics_counts()}, status=200)
def put(request): if is_url_out(request.data, 'url'): return JsonResponse( { 'Response': 'Database parameter URL in request data not found.' }, status=400) date = datetime.datetime.strptime(request.data['date'], '%d.%m.%Y').date() database_url = request.data['url'] statistics = Statistics(database_url) if statistics: statistics.add_statistics(request.data['user_id'], request.data['point'], date) return JsonResponse( {'Response': 'Statistic wars successfully added.'}, status=200)