Skip to content

Commit 1ebd5d1

Browse files
Cory feedback
1 parent a5bdec2 commit 1ebd5d1

3 files changed

Lines changed: 45 additions & 42 deletions

File tree

client/app/aggregations/aggregations.module.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
max-width: 1200px;
44
margin: 0 auto;
55
padding: 2rem;
6-
font-family: var(--font-system);
6+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
77
}
88

99
.title {
@@ -78,12 +78,10 @@
7878

7979
.year {
8080
font-weight: 600;
81-
color: #3498db;
8281
}
8382

8483
.rank {
8584
font-weight: 700;
86-
color: #e74c3c;
8785
}
8886

8987
.directorName {

client/app/aggregations/page.tsx

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,31 @@
11
import React from 'react';
22
import { fetchMoviesWithComments, fetchMoviesByYear, fetchDirectorStats } from '../lib/api';
3+
import { MovieWithComments, YearlyStats, DirectorStats } from '../types/aggregations';
34
import styles from './aggregations.module.css';
45

5-
// Type definitions for better type safety
6-
interface MovieWithComments {
7-
_id: string;
8-
title: string;
9-
year: number;
10-
genres: string[];
11-
imdbRating: number;
12-
totalComments: number;
13-
recentComments: Array<{
14-
userName: string;
15-
userEmail: string;
16-
text: string;
17-
date: string;
18-
}>;
19-
}
20-
21-
interface YearlyStats {
22-
year: number;
23-
movieCount: number;
24-
averageRating: number;
25-
highestRating: number;
26-
lowestRating: number;
27-
totalVotes: number;
28-
}
29-
30-
interface DirectorStats {
31-
director: string;
32-
movieCount: number;
33-
averageRating: number;
34-
}
35-
366
export default async function AggregationsPage() {
7+
const MOVIES_WITH_COMMENTS_LIMIT = 5;
8+
const DIRECTOR_STATS_LIMIT = 15;
379

3810
// Fetch all aggregation data with error handling
3911
const [commentsResult, yearResult, directorsResult] = await Promise.allSettled([
40-
fetchMoviesWithComments(5),
12+
fetchMoviesWithComments(MOVIES_WITH_COMMENTS_LIMIT),
4113
fetchMoviesByYear(),
42-
fetchDirectorStats(15)
14+
fetchDirectorStats(DIRECTOR_STATS_LIMIT)
4315
]);
4416

4517
// Process results with fallbacks
4618
const commentsData = commentsResult.status === 'fulfilled' ? commentsResult.value : { success: false, error: 'Failed to fetch comments data' };
4719
const yearData = yearResult.status === 'fulfilled' ? yearResult.value : { success: false, error: 'Failed to fetch year data' };
4820
const directorsData = directorsResult.status === 'fulfilled' ? directorsResult.value : { success: false, error: 'Failed to fetch directors data' };
4921

50-
console.log('Aggregations SSR: Data fetch completed', {
51-
comments: commentsData.success,
52-
year: yearData.success,
53-
directors: directorsData.success
54-
});
22+
if (process.env.NODE_ENV === 'development') {
23+
console.log('Aggregations SSR: Data fetch completed', {
24+
comments: commentsData.success,
25+
year: yearData.success,
26+
directors: directorsData.success
27+
});
28+
}
5529

5630
return (
5731
<div className={styles.container}>
@@ -85,7 +59,7 @@ export default async function AggregationsPage() {
8559
<td>
8660
<div className={styles.commentsContainer}>
8761
{movie.recentComments?.slice(0, 2).map((comment, index) => (
88-
<div key={index} className={styles.comment}>
62+
<div key={`${movie._id}-${comment.date}-${index}`} className={styles.comment}>
8963
<div className={styles.commentText}>
9064
&ldquo;{(comment.text || 'No text').slice(0, 80)}{comment.text?.length > 80 ? '...' : ''}&rdquo;
9165
</div>

client/app/types/aggregations.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Type definitions for aggregations page
2+
3+
export interface MovieWithComments {
4+
_id: string;
5+
title: string;
6+
year: number;
7+
genres: string[];
8+
imdbRating: number;
9+
totalComments: number;
10+
recentComments: Array<{
11+
userName: string;
12+
userEmail: string;
13+
text: string;
14+
date: string;
15+
}>;
16+
}
17+
18+
export interface YearlyStats {
19+
year: number;
20+
movieCount: number;
21+
averageRating: number;
22+
highestRating: number;
23+
lowestRating: number;
24+
totalVotes: number;
25+
}
26+
27+
export interface DirectorStats {
28+
director: string;
29+
movieCount: number;
30+
averageRating: number;
31+
}

0 commit comments

Comments
 (0)