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
31 changes: 0 additions & 31 deletions backend/routes/analyticsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,6 @@ router.get("/breakdown", getBreakdown);
router.get('/model-drift', checkModelDrift);
router.get("/me", getPersonalSummary);

router.get('/trends', protect, async (req, res) => {
try {
const { days = 7 } = req.query;
const userId = req.user.id;

const predictions = await History.find({
user: userId,
createdAt: { $gte: new Date(Date.now() - days * 24 * 60 * 60 * 1000) }
});

const trends = {};
predictions.forEach(p => {
const date = p.createdAt.toISOString().split('T')[0];
if (!trends[date]) trends[date] = { total: 0, spam: 0 };
trends[date].total++;
if (p.prediction === 'spam' || p.prediction === 'smishing') trends[date].spam++;
});

const result = Object.entries(trends).map(([date, d]) => ({
date,
total: d.total,
spam: d.spam
}));

res.json(result);
} catch (error) {
console.error('Trends error:', error);
res.status(500).json({ error: 'Failed to fetch trends' });
}
});

router.get("/breakdown", getBreakdown);
router.get('/model-drift', checkModelDrift);
router.get("/me", getPersonalSummary);
Expand Down
2 changes: 1 addition & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ app.use('/admin/queues', adminAuth, serverAdapter.getRouter());

app.use("/", predictionRoutes);
app.use("/", emailIntegrationRoutes);
app.use("/", imapRoutes);
app.use("/imap", imapRoutes);
app.use("/", utilityRoutes);
// Mounted after predictionRoutes so predictionRoutes' existing POST /bulk-predict
// handler keeps precedence; this only newly exposes GET /bulk-predict/template.
Expand Down
56 changes: 56 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,60 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}

location /gmail {
proxy_pass http://node-backend:3000/gmail;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}

location /outlook {
proxy_pass http://node-backend:3000/outlook;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}

location /scan-emails {
proxy_pass http://node-backend:3000/scan-emails;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}

location /analyze-email-header {
proxy_pass http://node-backend:3000/analyze-email-header;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}

location /bulk-predict {
proxy_pass http://node-backend:3000/bulk-predict;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}

location /spam-insights {
proxy_pass http://node-backend:3000/spam-insights;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}

location /imap {
proxy_pass http://node-backend:3000/imap;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
}
}
Loading