Add organizations v2 API and registry enrichment
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 26s
CI/CD Pipeline / Build and Push Images (push) Successful in 6s
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s

This commit is contained in:
2026-05-06 19:04:46 +02:00
parent f54aa4cb0b
commit 0f17ff6773
62 changed files with 10311 additions and 430 deletions

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,31 @@
"""Populate canonical organizations from existing source tables."""
from __future__ import annotations
import json
from apps.core.management.commands.base import BaseAppCommand
from organizations.services import OrganizationPopulationService
class Command(BaseAppCommand):
"""Populate organizations directory from current database records."""
help = "Заполняет справочник organizations.Organization из существующих данных БД"
use_transaction = True
def execute_command(self, *args, **options) -> str:
result = OrganizationPopulationService.populate()
rendered = json.dumps(
{
"scanned": result.scanned,
"created": result.created,
"updated": result.updated,
"skipped": result.skipped,
},
ensure_ascii=False,
sort_keys=True,
)
self.log_success(rendered)
return rendered

View File

@@ -0,0 +1,49 @@
"""Refresh precomputed organization data snapshots."""
from __future__ import annotations
import json
from apps.core.management.commands.base import BaseAppCommand
from organizations.services import OrganizationDataSnapshotRefreshService
class Command(BaseAppCommand):
"""Refresh organizations_data_snapshot rows for API v2."""
help = "Пересобирает organizations_data_snapshot для API v2"
use_transaction = False
def add_arguments(self, parser) -> None:
super().add_arguments(parser)
parser.add_argument(
"--uid",
action="append",
dest="uids",
default=None,
help="UID организации. Можно передать несколько раз.",
)
parser.add_argument(
"--batch-size",
type=int,
default=100,
help="Размер пачки организаций для пересборки.",
)
def execute_command(self, *args, **options) -> str:
result = OrganizationDataSnapshotRefreshService.refresh(
organization_uids=options.get("uids"),
batch_size=options["batch_size"],
)
rendered = json.dumps(
{
"processed": result.processed,
"created": result.created,
"updated": result.updated,
},
ensure_ascii=False,
sort_keys=True,
)
self.log_success(rendered)
return rendered