Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ def get_attack_types_daily(

end = datetime.now() - timedelta(days=offset_days)
cutoff = end - timedelta(days=days)
use_hourly = days <= 7
use_hourly = True

# Time range filter used by both queries
time_filter = [
Expand Down
14 changes: 2 additions & 12 deletions src/generative_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,20 +575,10 @@ async def generate_html_for_path(

except RuntimeError as err:
logger.error(f"AI generation failed for path {path}: {err}")
return (
"<html><body><h1>500 Internal Server Error</h1></body></html>",
"text/html",
500,
False,
)
raise
except Exception as err:
logger.error(f"Unexpected error in AI generation for path {path}: {err}")
return (
"<html><body><h1>500 Internal Server Error</h1></body></html>",
"text/html",
500,
False,
)
raise RuntimeError(f"AI generation failed: {err}") from err


def should_use_ai_for_path(path: str) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions src/templates/jinja2/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ <h2 style="margin: 0;">Attack Trends <span style="color: #8b949e; font-size: 0.7
<div style="display: flex; align-items: center; gap: 12px;">
<div style="display: flex; gap: 4px;" id="trends-span-selector">
<button class="map-limit-btn" data-days="1" onclick="setTrendsSpan(1, this)">1D</button>
<button class="map-limit-btn" data-days="7" onclick="setTrendsSpan(7, this)">7D</button>
<button class="map-limit-btn active" data-days="30" onclick="setTrendsSpan(30, this)">30D</button>
<button class="map-limit-btn active" data-days="7" onclick="setTrendsSpan(7, this)">7D</button>
<button class="map-limit-btn" data-days="30" onclick="setTrendsSpan(30, this)">30D</button>
</div>
<div style="display: flex; align-items: center; gap: 6px;">
<button id="trends-prev" onclick="shiftTrendsPeriod(-1)" class="pagination-btn" style="padding: 4px 10px; font-size: 0.85em;">&#8592;</button>
Expand Down
12 changes: 8 additions & 4 deletions src/templates/static/js/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async function loadAttackTypesChart(canvasId, ipFilter, legendPosition) {
*/
let attackTrendsChart = null;
let _trendsOffsetDays = 0;
let _trendsDays = 30;
let _trendsDays = 7;

// Hash-based consistent colors (shared with doughnut chart)
function _trendsHashCode(str) {
Expand Down Expand Up @@ -354,9 +354,13 @@ function _updateTrendsPeriodLabel(dates) {
return;
}

const start = new Date(dates[0] + 'T00:00:00');
const end = new Date(dates[dates.length - 1] + 'T00:00:00');
const fmt = { month: 'short', day: 'numeric' };
const isHourly = dates[0].includes(':');
const parseDate = d => isHourly ? new Date(d.replace(' ', 'T')) : new Date(d + 'T00:00:00');
const start = parseDate(dates[0]);
const end = parseDate(dates[dates.length - 1]);
const fmt = isHourly
? { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }
: { month: 'short', day: 'numeric' };
label.textContent = `${start.toLocaleDateString('en-US', fmt)} — ${end.toLocaleDateString('en-US', fmt)}`;
}

Expand Down
Loading