fix dashboard parser source counts
All checks were successful
CI/CD Pipeline / Manual Action Help (push) Has been skipped
CI/CD Pipeline / Start Dev Containers in Dokploy (push) Has been skipped
CI/CD Pipeline / Drop and Recreate Dev Database (push) Has been skipped
CI/CD Pipeline / Quality Gate (push) Successful in 1m12s
CI/CD Pipeline / Build and Push Images (push) Successful in 5m23s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s
All checks were successful
CI/CD Pipeline / Manual Action Help (push) Has been skipped
CI/CD Pipeline / Start Dev Containers in Dokploy (push) Has been skipped
CI/CD Pipeline / Drop and Recreate Dev Database (push) Has been skipped
CI/CD Pipeline / Quality Gate (push) Successful in 1m12s
CI/CD Pipeline / Build and Push Images (push) Successful in 5m23s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s
This commit is contained in:
@@ -2070,7 +2070,8 @@ class ParserDashboardDataView(APIView):
|
|||||||
file_sources = [source for source in sources if source["supports_file_upload"]]
|
file_sources = [source for source in sources if source["supports_file_upload"]]
|
||||||
jobs = BackgroundJobService.get_user_jobs(user_id=request.user.id, limit=30)
|
jobs = BackgroundJobService.get_user_jobs(user_id=request.user.id, limit=30)
|
||||||
source_counts = dict(
|
source_counts = dict(
|
||||||
GenericParserRecord.objects.values("source")
|
GenericParserRecord.objects.order_by()
|
||||||
|
.values("source")
|
||||||
.annotate(count=Count("id"))
|
.annotate(count=Count("id"))
|
||||||
.values_list("source", "count")
|
.values_list("source", "count")
|
||||||
)
|
)
|
||||||
@@ -2080,6 +2081,9 @@ class ParserDashboardDataView(APIView):
|
|||||||
for source, model in NATIVE_RECORD_MODELS.items()
|
for source, model in NATIVE_RECORD_MODELS.items()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
source_counts.update(
|
||||||
|
{ParserLoadLog.Source.FNS_REPORTS: FinancialReport.objects.count()}
|
||||||
|
)
|
||||||
schedules = [
|
schedules = [
|
||||||
_periodic_task_to_dict(task)
|
_periodic_task_to_dict(task)
|
||||||
for task in _parser_periodic_tasks_for_user(request.user)
|
for task in _parser_periodic_tasks_for_user(request.user)
|
||||||
|
|||||||
@@ -158,6 +158,36 @@ class ParsersViewSetTest(APITestCase):
|
|||||||
self.assertEqual(detail_response.data["data"]["payload"], {"registry": "44fz"})
|
self.assertEqual(detail_response.data["data"]["payload"], {"registry": "44fz"})
|
||||||
|
|
||||||
def test_dashboard_data_exposes_source_groups_for_page(self):
|
def test_dashboard_data_exposes_source_groups_for_page(self):
|
||||||
|
GenericParserRecord.objects.create(
|
||||||
|
load_batch=1,
|
||||||
|
source=ParserLoadLog.Source.PROCUREMENTS_44FZ,
|
||||||
|
external_id="eis-44fz-1",
|
||||||
|
title="EIS 44-FZ notice 1",
|
||||||
|
payload={"registry": "44fz"},
|
||||||
|
)
|
||||||
|
GenericParserRecord.objects.create(
|
||||||
|
load_batch=1,
|
||||||
|
source=ParserLoadLog.Source.PROCUREMENTS_44FZ,
|
||||||
|
external_id="eis-44fz-2",
|
||||||
|
title="EIS 44-FZ notice 2",
|
||||||
|
payload={"registry": "44fz"},
|
||||||
|
)
|
||||||
|
GenericParserRecord.objects.create(
|
||||||
|
load_batch=1,
|
||||||
|
source=ParserLoadLog.Source.TRUDVSEM,
|
||||||
|
external_id="trudvsem-1",
|
||||||
|
title="Vacancy",
|
||||||
|
payload={"registry": "trudvsem"},
|
||||||
|
)
|
||||||
|
FinancialReport.objects.create(
|
||||||
|
external_id=_digits(5),
|
||||||
|
ogrn=_digits(13),
|
||||||
|
file_name=f"fin_{_digits(5)}_{_digits(13)}.xlsx",
|
||||||
|
file_hash=fake.sha256(raw_output=False),
|
||||||
|
load_batch=1,
|
||||||
|
status=FinancialReport.Status.SUCCESS,
|
||||||
|
source=FinancialReport.SourceType.API,
|
||||||
|
)
|
||||||
self.client.force_authenticate(self.user)
|
self.client.force_authenticate(self.user)
|
||||||
|
|
||||||
response = self.client.get("/api/v1/parsers/dashboard/")
|
response = self.client.get("/api/v1/parsers/dashboard/")
|
||||||
@@ -182,6 +212,12 @@ class ParsersViewSetTest(APITestCase):
|
|||||||
sources["contracts"]["result_list_url"],
|
sources["contracts"]["result_list_url"],
|
||||||
"/api/v1/eis/contracts/",
|
"/api/v1/eis/contracts/",
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
payload["source_counts"][ParserLoadLog.Source.PROCUREMENTS_44FZ],
|
||||||
|
2,
|
||||||
|
)
|
||||||
|
self.assertEqual(payload["source_counts"][ParserLoadLog.Source.TRUDVSEM], 1)
|
||||||
|
self.assertEqual(payload["source_counts"][ParserLoadLog.Source.FNS_REPORTS], 1)
|
||||||
|
|
||||||
def test_financial_reports_list_and_retrieve(self):
|
def test_financial_reports_list_and_retrieve(self):
|
||||||
report = FinancialReport.objects.create(
|
report = FinancialReport.objects.create(
|
||||||
|
|||||||
Reference in New Issue
Block a user