Skip to content

Commit

Permalink
refactor: add YESTERDAY to DAQJobServeHTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Oct 13, 2024
1 parent 6d9e6cc commit 9e5618b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/daq/jobs/serve_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import socketserver
import threading
from dataclasses import dataclass
from datetime import datetime
from datetime import datetime, timedelta

from daq.base import DAQJob
from daq.models import DAQJobConfig
Expand Down Expand Up @@ -31,9 +31,15 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, directory=serve_path, **kwargs)

def do_GET(self) -> None:
self.path = self.path.replace(
"TODAY", datetime.now().strftime("%Y-%m-%d")
)
REPLACE_DICT = {
"TODAY": datetime.now().strftime("%Y-%m-%d"),
"YESTERDAY": (datetime.now() - timedelta(days=1)).strftime(
"%Y-%m-%d"
),
}
for key, value in REPLACE_DICT.items():
self.path = self.path.replace(key, value)

return super().do_GET()

def log_message(self, format: str, *args) -> None:
Expand Down

0 comments on commit 9e5618b

Please sign in to comment.