From 2d91524f7511000420858599e498d93ff22fef38 Mon Sep 17 00:00:00 2001 From: timofejmalinin Date: Sun, 8 Oct 2023 16:16:28 +0400 Subject: [PATCH] new views funcs --- deploy/django.yml | 2 +- service/management/commands/create_views.py | 8 ++++++-- service/management/commands/delete_views.py | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/deploy/django.yml b/deploy/django.yml index 6532f31..a3e12c9 100644 --- a/deploy/django.yml +++ b/deploy/django.yml @@ -19,7 +19,7 @@ spec: containers: - name: django image: DEPLOY_IMAGE_TAG - command: ["sh", "-c", "python manage.py delete_views && python manage.py create_procedures && python manage.py migrate && python manage.py create_views && python manage.py runserver 0.0.0.0:${DJANGO_PORT}"] + command: ["sh", "-c", "python manage.py delete_views && python manage.py migrate && python manage.py create_views && python manage.py runserver 0.0.0.0:${DJANGO_PORT}"] ports: - containerPort: 8000 name: django-port diff --git a/service/management/commands/create_views.py b/service/management/commands/create_views.py index af56451..fa284fc 100644 --- a/service/management/commands/create_views.py +++ b/service/management/commands/create_views.py @@ -1,9 +1,13 @@ from django.core.management.base import BaseCommand from service.utils import run_sql_command, log_to_telegram -CMD_PIVOT_DIST = """CALL public.pivot_dist();""" +CMD_PIVOT_DIST = """CREATE OR REPLACE VIEW compact_placementpoint AS +SELECT id, status, category, age_day, fact, area_id, district_id, prediction_first, prediction_current, doors, flat_cnt, rival_post_cnt, rival_pvz_cnt, target_post_cnt, flats_cnt, tc_cnt, culture_cnt, mfc_cnt, public_stop_cnt, supermarket_cnt, target_dist, metro_dist, geometry, d10,d12,d17,d20,d24,d25,d7,d8,d9 FROM service_placementpoint; +""" -CMD_PIVOT_DIST_PRE = """CALL public.prepivot_dist();""" +CMD_PIVOT_DIST_PRE = """CREATE OR REPLACE VIEW compact_preplacementpoint AS +SELECT id, status, category, age_day, fact, area_id, district_id, prediction_first, prediction_current, doors, flat_cnt, rival_post_cnt, rival_pvz_cnt, target_post_cnt, flats_cnt, tc_cnt, culture_cnt, mfc_cnt, public_stop_cnt, supermarket_cnt, target_dist, metro_dist, geometry, d10,d12,d17,d20,d24,d25,d7,d8,d9 FROM service_preplacementpoint; +""" class Command(BaseCommand): help = 'Create views' diff --git a/service/management/commands/delete_views.py b/service/management/commands/delete_views.py index 3182b8f..83d58fc 100644 --- a/service/management/commands/delete_views.py +++ b/service/management/commands/delete_views.py @@ -1,9 +1,10 @@ from django.core.management.base import BaseCommand from service.utils import run_sql_command, log_to_telegram -CMD_PIVOT_DIST = """drop view points_with_dist;""" -CMD_PIVOT_DIST_PRE = """drop view prepoints_with_dist;""" +CMD_PIVOT_DIST = """drop view compact_placementpoint;""" + +CMD_PIVOT_DIST_PRE = """drop view compact_preplacementpoint;""" class Command(BaseCommand): help = 'delete views'