Skip to content

Commit

Permalink
refactor: make csv store use add_date_to_file_name to modify `file_…
Browse files Browse the repository at this point in the history
…path`
  • Loading branch information
furkan-bilgin committed Oct 11, 2024
1 parent 34157c8 commit 0ce2c6c
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/daq/store/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from daq.models import DAQJobConfig
from daq.store.base import DAQJobStore
from daq.store.models import DAQJobMessageStore, DAQJobStoreConfig
from utils.file import add_date_to_file_name


@dataclass
Expand All @@ -34,18 +35,7 @@ def __init__(self, config: Any):
def handle_message(self, message: DAQJobMessageStore) -> bool:
super().handle_message(message)
store_config = cast(DAQJobStoreConfigCSV, message.store_config)
file_path = store_config.file_path

# Append date to file name if specified
if store_config.add_date:
splitted_file_path = os.path.splitext(file_path)
date_text = datetime.now().strftime("%Y-%m-%d")
if len(splitted_file_path) > 1:
file_path = (
f"{splitted_file_path[0]}_{date_text}{splitted_file_path[1]}"
)
else:
file_path = f"{splitted_file_path[0]}_{date_text}"
file_path = add_date_to_file_name(store_config.file_path, store_config.add_date)

self._logger.debug(
f"Handling message for DAQ Job: {type(message.daq_job).__name__}"
Expand Down

0 comments on commit 0ce2c6c

Please sign in to comment.