fixed code quality

This commit is contained in:
Muhammad Ibrahim
2025-11-06 22:16:35 +00:00
parent a8eb3ec21c
commit 8e5eb54e02
2 changed files with 16 additions and 32 deletions

View File

@@ -52,7 +52,7 @@ function init(server, prismaClient) {
// Echo back for Bull Board WebSocket
try {
ws.send(message);
} catch (err) {
} catch (_err) {
// Ignore send errors (connection may be closed)
}
});
@@ -160,9 +160,7 @@ function init(server, prismaClient) {
err.message?.includes("read ECONNRESET")
) {
// Connection reset errors are common and expected
console.log(
`[agent-ws] connection reset for ${apiId}`,
);
console.log(`[agent-ws] connection reset for ${apiId}`);
} else {
// Log other errors for debugging
console.error(
@@ -181,7 +179,10 @@ function init(server, prismaClient) {
}
// Try to close the connection gracefully if still open
if (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING) {
if (
ws.readyState === WebSocket.OPEN ||
ws.readyState === WebSocket.CONNECTING
) {
try {
ws.close(1000); // Normal closure
} catch {

View File

@@ -30,24 +30,8 @@ function get_current_time() {
// For other timezones, we need to create a date string with timezone info
// and parse it. This ensures the date represents the correct time in that timezone.
const now = new Date();
const formatter = new Intl.DateTimeFormat("en-US", {
timeZone: tz,
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
});
const parts = formatter.formatToParts(now);
const date_str = `${parts.find((p) => p.type === "year").value}-${parts.find((p) => p.type === "month").value}-${parts.find((p) => p.type === "day").value}T${parts.find((p) => p.type === "hour").value}:${parts.find((p) => p.type === "minute").value}:${parts.find((p) => p.type === "second").value}`;
// Create date in UTC, then adjust to represent the same moment in the target timezone
// This is a bit tricky - we'll use a simpler approach: store as UTC but display in timezone
// For database storage, we always store UTC timestamps
// The timezone is primarily used for display purposes
return new Date();
}
@@ -88,7 +72,7 @@ function parse_date(date_string, fallback = null) {
return fallback || get_current_time();
}
return date;
} catch (error) {
} catch (_error) {
return fallback || get_current_time();
}
}
@@ -121,4 +105,3 @@ module.exports = {
parse_date,
format_date_for_display,
};