From eeb75d8ef47d47dbecf24690d43781fe5b940cb1 Mon Sep 17 00:00:00 2001 From: saladgg Date: Fri, 1 Sep 2023 12:32:17 +0300 Subject: [PATCH] chore: remove pubsub no longer required --- apps/sql_data/models.py | 30 ------------------------------ apps/sql_data/tests/test_models.py | 7 +++++++ requirements/base.txt | 1 - 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/apps/sql_data/models.py b/apps/sql_data/models.py index f7d7d1a..f1481c0 100644 --- a/apps/sql_data/models.py +++ b/apps/sql_data/models.py @@ -188,36 +188,6 @@ def upload_data_dir(self) -> str: def mark_as_complete(self, user=None) -> None: self.update(modifier=user, finish_time=timezone.now()) - # TODO: This should be replaced with the observer pattern. - self._publish_to_pubsub() - - def _publish_to_pubsub(self) -> None: - # TODO: Implement this functionality properly and DELETE this!!! - import json - import os - - from google.cloud import pubsub_v1 - - message_payload = json.dumps( - obj={ - "org_unit_code": self.org_unit_code, - "org_unit_name": self.org_unit_name, - "content_type": self.content_type, - "extract_metadata": str(self.extract_metadata.id), - "extract_type": self.extract_metadata.name, - "chunks_count": self.chunks_count, - "upload_id": str(self.id), - "uploads_data_dir": self.upload_data_dir, - "start_time": str(self.start_time), - "finish_time": str(self.finish_time), - }, - check_circular=True, - ) - publisher = pubsub_v1.PublisherClient() - topic_id = os.getenv("PUB_SUB_TOPIC") - project_id = os.getenv("GOOGLE_CLOUD_PROJECT") - topic_path = publisher.topic_path(project_id, topic_id) - publisher.publish(topic_path, message_payload.encode("utf-8")) class Meta(AbstractExtractMetadata.Meta): verbose_name_plural = "Sql upload metadata" diff --git a/apps/sql_data/tests/test_models.py b/apps/sql_data/tests/test_models.py index aa990d6..9cf6420 100644 --- a/apps/sql_data/tests/test_models.py +++ b/apps/sql_data/tests/test_models.py @@ -70,6 +70,13 @@ def setUp(self): super().setUp() self.sql_upload_metadata = baker.make(SQLUploadMetadata) + def test_chunks_count(self): + chunk = baker.make( + SQLUploadChunk, upload_metadata=self.sql_upload_metadata + ) + chunk.save() + assert self.sql_upload_metadata.chunks_count == 1 + def test_data_source_name(self): data_source = self.sql_upload_metadata.data_source_name data_source_name = ( diff --git a/requirements/base.txt b/requirements/base.txt index 85ce808..27e87f7 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -14,7 +14,6 @@ Django~=4.2 djangorestframework~=3.14.0 environs~=9.5.0 google-auth~=2.17.1 -google-cloud-pubsub~=2.15.2 openpyxl~=3.1.2 psycopg~=3.1.8 psycopg-binary~=3.1.8