fix: resolve multiple feedback management issues
Mirror to GitHub / mirror (push) Successful in 44s
Test and Lint / backend-test (push) Successful in 1m22s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m1s
Version and Release / version-bump (push) Successful in 40s
Version and Release / trigger-drone (push) Successful in 3s
Mirror to GitHub / mirror (push) Successful in 44s
Test and Lint / backend-test (push) Successful in 1m22s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m1s
Version and Release / version-bump (push) Successful in 40s
Version and Release / trigger-drone (push) Successful in 3s
- Hide "Manage Feedback" button when feedback is disabled for an event - Fix 500 error on feedback API endpoint by adding null-safe operators - Fix TypeError on analytics page by calculating average_rating in backend - Fix password validation for event creation by properly awaiting async validation - Add proper null checks and fallbacks for feedback statistics These fixes ensure: - Date passwords like "19.07.2025" work with simple password complexity settings - Feedback management page loads without errors - Analytics display correctly even with no feedback data 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,7 @@ router.post('/', adminAuth, [
|
||||
} = req.body;
|
||||
|
||||
// Validate password strength for gallery
|
||||
const passwordValidation = validatePasswordInContext(password, 'gallery', {
|
||||
const passwordValidation = await validatePasswordInContext(password, 'gallery', {
|
||||
eventName: event_name
|
||||
});
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ router.post('/', adminAuth, [
|
||||
} = req.body;
|
||||
|
||||
// Validate password strength
|
||||
const passwordValidation = validatePasswordInContext(password, 'gallery', {
|
||||
const passwordValidation = await validatePasswordInContext(password, 'gallery', {
|
||||
eventName: event_name
|
||||
});
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@ router.get('/events/:eventId/feedback',
|
||||
pagination: {
|
||||
page: parseInt(page),
|
||||
limit: parseInt(limit),
|
||||
total: totalCount.count || 0,
|
||||
pages: Math.ceil((totalCount.count || 0) / limit)
|
||||
total: totalCount?.count || 0,
|
||||
pages: Math.ceil((totalCount?.count || 0) / limit)
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -182,7 +182,35 @@ router.get('/events/:eventId/feedback-analytics',
|
||||
const { eventId } = req.params;
|
||||
|
||||
// Get summary statistics
|
||||
const summary = await feedbackService.getEventFeedbackSummary(eventId);
|
||||
const summaryData = await feedbackService.getEventFeedbackSummary(eventId);
|
||||
|
||||
// Calculate average rating and other summary stats
|
||||
const avgRatingResult = await db('photo_feedback')
|
||||
.where('event_id', eventId)
|
||||
.where('feedback_type', 'rating')
|
||||
.avg('rating as average_rating')
|
||||
.first();
|
||||
|
||||
const pendingModeration = await db('photo_feedback')
|
||||
.where('event_id', eventId)
|
||||
.where('feedback_type', 'comment')
|
||||
.where('is_approved', false)
|
||||
.where('is_hidden', false)
|
||||
.count('* as count')
|
||||
.first();
|
||||
|
||||
const summary = {
|
||||
average_rating: parseFloat(avgRatingResult?.average_rating || 0),
|
||||
total_ratings: summaryData.stats?.total_ratings || 0,
|
||||
total_likes: summaryData.stats?.total_likes || 0,
|
||||
total_comments: summaryData.stats?.total_comments || 0,
|
||||
total_favorites: summaryData.stats?.total_favorites || 0,
|
||||
pending_moderation: pendingModeration?.count || 0,
|
||||
total_feedback: (summaryData.stats?.total_ratings || 0) +
|
||||
(summaryData.stats?.total_likes || 0) +
|
||||
(summaryData.stats?.total_comments || 0) +
|
||||
(summaryData.stats?.total_favorites || 0)
|
||||
};
|
||||
|
||||
// Get top-rated photos
|
||||
const topRated = await db('photos')
|
||||
|
||||
Reference in New Issue
Block a user