Merge branch 'fix_ml-2' into 'dev'

fixes

See merge request spatial/postamates!126
dev
Aleksandr Popov 2 years ago
commit 0d61a86630

@ -67,6 +67,7 @@ class CategoryAdmin(admin.ModelAdmin):
class PostPvzCategoryAdmin(CategoryAdmin):
def save_model(self, request, obj, form, change):
obj.save()
run_psql_command()
if 'include_in_ml' in form.changed_data or 'visible' in form.changed_data:
LayerService.update_categories(obj)
cache.clear()
@ -92,9 +93,8 @@ class GroupAdmin(admin.ModelAdmin):
class PostPvzGroupAdmin(GroupAdmin):
def save_model(self, request, obj, form, change):
if not obj.pk:
run_psql_command()
obj.save()
run_psql_command()
if 'include_in_ml' in form.changed_data or 'visible' in form.changed_data:
LayerService.update_groups(obj)
cache.clear()

@ -25,10 +25,11 @@ from io import StringIO
from django.core.cache import cache
from service.layer_service import LayerService
from service.service import PointService
from service.utils import run_psql_command
@shared_task()
def raschet(table_name='service_placementpoint'):
def raschet(table_name='service_placementpoint', need_time=True):
print('start raschet')
status, _ = models.TaskStatus.objects.get_or_create(task_name=STATUS_TASK_NAME)
raschet_objs = models.RaschetObjects.objects.all()
@ -319,12 +320,15 @@ def raschet(table_name='service_placementpoint'):
conn2.close()
cache.clear()
log_to_telegram('end raschet')
run_psql_command()
status.status = 'Перерасчет ML завершен'
status.save()
if need_time:
LastMLCall.objects.all().delete()
LastMLCall.objects.create()
@shared_task
def load_post_and_pvz(obj_id: int):
file = models.TempFiles.objects.get(id=obj_id)

@ -24,7 +24,7 @@ def run_psql_command():
)
try:
cursor = connection.cursor()
command = "CALL public.pivot_dist();"
command = "CALL public.pivot_dist();CALL public.prepivot_dist();"
cursor.execute(command)
connection.commit()
except psycopg2.Error as e:

@ -367,7 +367,7 @@ class PrePlacementPointViewSet(PlacementPointViewSet):
file_id = request.POST['id']
total, matched, problem = PointService().start_mathing(file_id)
PointService().make_enrichment()
raschet('service_preplacementpoint')
raschet('service_preplacementpoint', need_time=False)
return Response(
{'message': {'total': total, 'matched': matched, 'error': problem, 'unmatched': total - matched - problem}},
status=HTTPStatus.OK,

Loading…
Cancel
Save