File tree Expand file tree Collapse file tree 4 files changed +22
-10
lines changed
Expand file tree Collapse file tree 4 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,7 @@ const Comment = ({ comment }) => {
214214 { comment . optimistic ? (
215215 < CircularProgress size = { 20 } />
216216 ) : (
217- comment . authorId === user . id && (
217+ comment . authorId === user ? .id && (
218218 < MoreButton
219219 setEditing = { setEditing }
220220 comment = { comment }
Original file line number Diff line number Diff line change @@ -283,12 +283,19 @@ const UserMetrics = () => {
283283 title = "Comments Received"
284284 value = { metrics . commentsReceived }
285285 />
286- < MetricItem
287- title = "Longest Post"
288- value = { `${ metrics . longestPost ?. words } words` }
289- isLink
290- linkTo = { `/posts/${ metrics . longestPost ?. id } ` }
291- />
286+ { metrics . longestPost ? (
287+ < MetricItem
288+ title = "Longest Post"
289+ value = { `${ metrics . longestPost . words } words` }
290+ isLink
291+ linkTo = { `/posts/${ metrics . longestPost . id } ` }
292+ />
293+ ) : (
294+ < MetricItem
295+ title = "Longest Post"
296+ value = { 0 }
297+ />
298+ ) }
292299 </ Grid >
293300 ) }
294301 </ ListItem >
Original file line number Diff line number Diff line change @@ -107,7 +107,12 @@ export const getUserStats = async ({ params: { id } }: RequestParams) => {
107107 } )
108108
109109 const commentsReceived = await prisma . comment . count ( {
110- where : { post : { authorId : id } } ,
110+ where : {
111+ AND : {
112+ post : { authorId : id } ,
113+ NOT : { authorId : id } ,
114+ } ,
115+ } ,
111116 } )
112117 try {
113118 const result = await prisma . $queryRaw < { id : string ; words : number } [ ] > `
@@ -127,7 +132,7 @@ export const getUserStats = async ({ params: { id } }: RequestParams) => {
127132 return {
128133 posts,
129134 privatePosts,
130- reactionsReceived : reactionsReceived . _sum . reactionCount ,
135+ reactionsReceived : reactionsReceived . _sum . reactionCount || 0 ,
131136 commentsReceived,
132137 longestPost : result [ 0 ] ,
133138 }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const prismaClientSingleton = () =>
1212 fullName : {
1313 needs : { firstName : true , lastName : true } ,
1414 compute ( user ) {
15- return `${ user . firstName } ${ user . lastName } `
15+ return `${ user . firstName } ${ user . lastName || '' } `
1616 } ,
1717 } ,
1818 } ,
You can’t perform that action at this time.
0 commit comments