feat: import additional exchange sections
All checks were successful
CI/CD Pipeline / Code Quality Checks (push) Successful in 2m41s
CI/CD Pipeline / Run Tests (push) Successful in 2m47s
CI/CD Pipeline / Build Docker Images (push) Successful in 2m24s
CI/CD Pipeline / Push to Gitea Registry (push) Successful in 0s
CI/CD Pipeline / Deploy to Server (push) Successful in 0s
All checks were successful
CI/CD Pipeline / Code Quality Checks (push) Successful in 2m41s
CI/CD Pipeline / Run Tests (push) Successful in 2m47s
CI/CD Pipeline / Build Docker Images (push) Successful in 2m24s
CI/CD Pipeline / Push to Gitea Registry (push) Successful in 0s
CI/CD Pipeline / Deploy to Server (push) Successful in 0s
This commit is contained in:
@@ -746,11 +746,16 @@ class OrganizationAnalyticsService:
|
||||
return base_rows
|
||||
|
||||
if frequency == "annual":
|
||||
return [cls._aggregate_product_metrics(base_rows, str(records[0].report_year))]
|
||||
return [
|
||||
cls._aggregate_product_metrics(base_rows, str(records[0].report_year))
|
||||
]
|
||||
|
||||
if frequency == "semiannual":
|
||||
grouped_rows: list[dict[str, object]] = []
|
||||
periods = ((1, 2, f"{records[0].report_year}-H1"), (3, 4, f"{records[0].report_year}-H2"))
|
||||
periods = (
|
||||
(1, 2, f"{records[0].report_year}-H1"),
|
||||
(3, 4, f"{records[0].report_year}-H2"),
|
||||
)
|
||||
for quarter_start, quarter_end, period in periods:
|
||||
half_rows = [
|
||||
row
|
||||
@@ -792,10 +797,11 @@ class OrganizationAnalyticsService:
|
||||
@staticmethod
|
||||
def _product_row_shipped_goods_amount(row: dict[str, object]) -> int:
|
||||
metrics = row["metrics"]
|
||||
return _amount(metrics["military_domestic_amount"]) + _amount(
|
||||
metrics["military_export_amount"]
|
||||
) + _amount(metrics["civilian_domestic_amount"]) + _amount(
|
||||
metrics["civilian_export_amount"]
|
||||
return (
|
||||
_amount(metrics["military_domestic_amount"])
|
||||
+ _amount(metrics["military_export_amount"])
|
||||
+ _amount(metrics["civilian_domestic_amount"])
|
||||
+ _amount(metrics["civilian_export_amount"])
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
"""Serializer contracts for OpenAPI documentation."""
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
from apps.organization.serializers import (
|
||||
CorporationScopeDictionarySerializer,
|
||||
OrganizationCatalogDetailSerializer,
|
||||
OrganizationCatalogListSerializer,
|
||||
)
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class OrganizationCatalogListResponseSerializer(serializers.Serializer):
|
||||
|
||||
@@ -67,9 +67,7 @@ def scope_labels(scope_codes: Iterable[str]) -> list[str]:
|
||||
def get_corporation_scope_dictionary() -> list[dict[str, str | int]]:
|
||||
"""Возвращает справочник корпусов для API-словаря."""
|
||||
items: list[dict[str, str | int]] = []
|
||||
for code, sort_order in sorted(
|
||||
SCOPE_SORT_ORDER.items(), key=lambda item: item[1]
|
||||
):
|
||||
for code, sort_order in sorted(SCOPE_SORT_ORDER.items(), key=lambda item: item[1]):
|
||||
label = SCOPE_LABELS.get(code)
|
||||
short_name = SCOPE_SHORT_NAMES.get(code)
|
||||
if not label or not short_name:
|
||||
|
||||
@@ -145,7 +145,6 @@ class OrganizationCatalogBaseSerializer(serializers.ModelSerializer):
|
||||
return SCOPE_LABELS.get(scope_code, "")
|
||||
|
||||
|
||||
|
||||
class OrganizationCatalogListSerializer(OrganizationCatalogBaseSerializer):
|
||||
"""Сериализатор списка организаций для `/api/v1/organizations/`."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user