Skip to content

Commit d1dd5a0

Browse files
authored
DBC22-5170: fixed the highway name underscore issue and added sql server driver installation back in the backend docker file (#1096)
* DBC22-5170: avoid to update highway name in huey task * DBC22-5170: add sql server driver back and fixed highway name underscore issue * DBC22-5170: add sql server driver back and fixed highway name underscore issue * DBC22-5170: add sql server driver back and fixed highway name underscore issue
1 parent 30d7f73 commit d1dd5a0

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

compose/backend/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ RUN apt-get update \
1313
&& apt-get clean \
1414
&& rm -rf /var/lib/apt/lists/*
1515

16+
# Install dependencies for SQL database connection
17+
RUN apt-get update && \
18+
apt-get install -y --no-install-recommends curl gnupg2 apt-transport-https && \
19+
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /usr/share/keyrings/microsoft-prod.gpg && \
20+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/debian/12/prod bookworm main" > /etc/apt/sources.list.d/mssql-release.list && \
21+
apt-get update && \
22+
ACCEPT_EULA=Y apt-get install -y --no-install-recommends msodbcsql17 unixodbc-dev gcc g++ && \
23+
apt-get clean && \
24+
rm -rf /var/lib/apt/lists/*
25+
26+
27+
1628
# Adding backend directory to make absolute filepaths consistent across services
1729
WORKDIR /app/backend
1830

src/backend/apps/consumer/processor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# PVC path to watermarked images with timestamp for ReplayTheDay
3737
PVC_WATERMARKED_PATH = os.getenv("PVC_WATERMARKED_PATH")
3838
# PVC path to watermarked images for current DriveBC without timestamp
39-
DRIVCBC_PVC_WATERMARKED_PATH = os.getenv("DRIVCBC_PVC_WATERMARKED_PATH")
39+
DRIVEBC_PVC_WATERMARKED_PATH = os.getenv("DRIVEBC_PVC_WATERMARKED_PATH")
4040

4141
logger = logging.getLogger(__name__)
4242
logger.setLevel(logging.INFO)
@@ -320,9 +320,9 @@ def save_watermarked_image_to_pvc(camera_id: str, image_bytes: bytes, timestamp:
320320
logger.error(f"Error saving Watermarked image to PVC {filepath}: {e}")
321321

322322
def save_watermarked_image_to_drivebc_pvc(camera_id: str, image_bytes: bytes):
323-
os.makedirs(os.path.dirname(f'{DRIVCBC_PVC_WATERMARKED_PATH}'), exist_ok=True)
323+
os.makedirs(os.path.dirname(f'{DRIVEBC_PVC_WATERMARKED_PATH}'), exist_ok=True)
324324

325-
save_dir = os.path.join(DRIVCBC_PVC_WATERMARKED_PATH)
325+
save_dir = os.path.join(DRIVEBC_PVC_WATERMARKED_PATH)
326326
os.makedirs(save_dir, exist_ok=True)
327327
filename = f"{camera_id}.jpg"
328328
filepath = os.path.join(save_dir, filename)

src/backend/apps/webcam/tasks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ def update_webcam_db(cam_id: int, cam_data: dict):
155155
time_now_utc = datetime.datetime.now(timezone.utc).strftime("%Y%m%d%H%M%S%f")[:-3]
156156
camera_status = calculate_camera_status(time_now_utc)
157157

158+
159+
raw_highway = cam_data.get("highway", "")
158160
updated_count = Webcam.objects.filter(id=cam_id).update(
159161
region_name=cam_data.get("region_name"),
160162
is_on=True if cam_data.get("isOn") == 1 else False,
161163
name=cam_data.get("cam_internetname"),
162164
caption=cam_data.get("cam_internetcaption", ""),
163-
highway=cam_data.get("highway", ""),
165+
highway=raw_highway.split("_", 1)[1] if "_" in raw_highway else int(raw_highway),
164166
highway_description=cam_data.get("highway_description", ""),
165167
orientation=cam_data.get("orientation", ""),
166168
elevation=cam_data.get("elevation", 0),

0 commit comments

Comments
 (0)