From c0fcf8092cbbc570388b57d7386f09699a989a54 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Mon, 19 Apr 2021 18:59:54 +0900 Subject: [PATCH] Add service for export dataset --- app/api/views/download/service.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/api/views/download/service.py diff --git a/app/api/views/download/service.py b/app/api/views/download/service.py new file mode 100644 index 00000000..84c1189e --- /dev/null +++ b/app/api/views/download/service.py @@ -0,0 +1,14 @@ +from .repositories import BaseRepository +from .writer import BaseWriter + + +class ExportApplicationService: + + def __init__(self, repository: BaseRepository, writer: BaseWriter): + self.repository = repository + self.writer = writer + + def export(self, export_approved=False) -> str: + records = self.repository.list(export_approved=export_approved) + filepath = self.writer.write(records) + return filepath