From bf6afc743069a32ca42549e37e55c64115cb809a Mon Sep 17 00:00:00 2001 From: zakhy <=> Date: Wed, 15 Jan 2025 09:48:58 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/seismicproc/views/views_main.py | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/seismicproc/views/views_main.py b/apps/seismicproc/views/views_main.py index 6c662fb..958d332 100644 --- a/apps/seismicproc/views/views_main.py +++ b/apps/seismicproc/views/views_main.py @@ -137,25 +137,25 @@ def main_index(request): def earthquake_list(request): - two_days_ago = datetime.datetime.now() - datetime.timedelta(days=2) - earthquakes = (Earthquake.objects. - filter(date_time__gt=two_days_ago). - order_by("-date_time"). - all()) - res = [] - for earthquake in earthquakes: - # Формула для вычисления радиуса землетрясения - power = 0.5 * earthquake.magnitude - math.log10(earthquake.depth) - 1.2 - radius = 10 ** power - res.append({ - 'id': earthquake.id, - 'time': earthquake.date_time, - 'lat': earthquake.latitude, - 'lon': earthquake.longitude, - 'depth': earthquake.depth, - 'magnitude': earthquake.magnitude, - 'region': earthquake.region, - 'source': earthquake.source, - 'radius': radius - }) - return JsonResponse(res, safe=False) + try: + two_days_ago = datetime.datetime.now() - datetime.timedelta(days=2) + earthquakes = (Earthquake.objects. + filter(date_time__gt=two_days_ago). + order_by("-date_time"). + all()) + res = [] + for earthquake in earthquakes: + # Формула для вычисления радиуса землетрясения + res.append({ + 'id': earthquake.id, + 'time': earthquake.date_time, + 'lat': earthquake.latitude, + 'lon': earthquake.longitude, + 'depth': earthquake.depth, + 'magnitude': earthquake.magnitude, + 'region': earthquake.region, + 'source': earthquake.source, + }) + return JsonResponse(res, safe=False) + except Exception as err: + logging.error(traceback.format_exc()) \ No newline at end of file