-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database redesign #136
base: main
Are you sure you want to change the base?
Database redesign #136
Conversation
e79b89f
to
3e11355
Compare
app/common/types.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try to avoid type definitions that are independent of our Prisma Schema where possible. This would avoid having to use casts like in L49 of CollaborationQuestionCard.tsx, where we know the type is correct because the the database gives us a createdAt property for every comment but it doesn't align with the type we defined elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to issue #158
@@ -41,9 +46,9 @@ export const CollaborationQuestionCard = ({ | |||
}: CollaborationQuestionCardProps) => { | |||
const { title, description, authors, comments: projectComments } = content; | |||
const { setCollaborationCommentsAmount } = useProject(); | |||
const sortedProjectComments = sortDateByCreatedAtDesc(projectComments); | |||
const sortedProjectComments = sortDateByCreatedAtDesc(projectComments as CollaborationCommentWithDate[]); //todo check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the todo if it's done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ✅
return ( | ||
<Stack direction={'row'}> | ||
<UpvoteControls upvoteCount={upvoteCount} isUpvoted={isUpvoted} onUpvote={onUpvote} sx={{ mr: 0.5 }} /> | ||
{/* <UpvoteControls upvoteCount={upvoteCount} isLiked={isLiked} onUpvote={onUpvote} sx={{ mr: 0.5 }} /> */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the "UpvoteControls" component used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with LikeControls and removed UpvoteControls ✅
upvoteCount, | ||
isUpvoted, | ||
onUpvote, | ||
// likeCount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed if it's not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed ✅
app/messages/de.json
Outdated
@@ -34,6 +34,7 @@ | |||
"components_collaboration_comments_collaborationCommentCard_upvoteError": "Der Kommentar konnte nicht hochgestuft werden. Bitte versuche es später noch einmal.", | |||
"components_collaboration_comments_collaborationCommentCard_updateError": "Der Kommentar konnte nicht aktualisiert werden. Bitte versuche es später noch einmal.", | |||
"components_collaboration_comments_collaborationCommentCard_deleteError": "Der Kommentar konnte nicht gelöscht werden. Bitte versuche es später noch einmal.", | |||
"components_collaboration_comments_collaborationCommentCard_questionMissing": "Die Frage konnte nicht gefunden werden. Bitte versuche es später noch einmal.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The translation is not used anywhere within the collaboration comment card
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed ✅
app/utils/newsFeed/redis/models.ts
Outdated
commentId: string; | ||
comment: string; | ||
author?: string; | ||
// commentId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed ✅
return comments.map((comment: RedisHashedNewsComment) => { | ||
//todo add likes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining todo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed ✅
@@ -73,11 +73,6 @@ | |||
"relation": "manyToMany", | |||
"target": "api::opportunity.opportunity", | |||
"mappedBy": "participants" | |||
}, | |||
"username": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The username
field should be kept in Strapi "InnoUser" collection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed forgotten files ✅
@@ -928,7 +928,6 @@ export interface ApiInnoUserInnoUser extends Schema.CollectionType { | |||
'manyToMany', | |||
'api::opportunity.opportunity' | |||
>; | |||
username: Attribute.String & Attribute.Unique; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to the "username" field, should be updated automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed forgotten files ✅
app/repository/db/comment.ts
Outdated
return comment?.likes; | ||
} | ||
|
||
//todo check this ObjectType.COMMENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this todo still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, removed (refactored too)
const getUpvotes = comments.map(async (comment): Promise<Comment> => { | ||
const { data: isUpvotedByUser } = await isProjectCommentUpvotedByUser({ commentId: comment.id }); | ||
const dbComments = await getCommentsByObjectId(dbClient, body.projectId); | ||
const comments = await Promise.all(dbComments.map((comment) => mapToComment(comment))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we want the comments sorted by createdAt DESC (sortDateByCreatedAtDesc
method) or sort them in the Comments Card.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not done, sorry :(
const commentCount = await getCommentResponseCount(dbClient, deletedResponse.parentId); | ||
await updateCollaborationCommentInCache({ user, comment: { id: deletedResponse.parentId, commentCount } }); | ||
} else { | ||
logger.info('no parentID'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the logging can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const body = { id: comment.objectId, commentCount }; | ||
return comment.objectType === 'POST' | ||
? await updatePostInCache({ post: body, user: author }) | ||
: await updateProjectUpdateInCache({ update: body }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why we're saving author of the POST, but not of the UPDATE to the cache?
const author = await getInnoUserByProviderId(comment.author); | ||
const likedBy = await Promise.allSettled( | ||
comment.likes.map(async (like) => await getInnoUserByProviderId(like.likedBy)), | ||
).then((results) => getFulfilledResults(results)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a helper function which makes the "promises" a bit less complicated syntax wise. Could you please change this to:
`const getLikedBy = comment.likes.map(async (like) => await getInnoUserByProviderId(like.likedBy));
const likedBy = await getPromiseResults(getLikedBy);`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ✅
question: CollaborationQuestion, | ||
): Promise<CollaborationComment[]> => { | ||
return await Promise.allSettled( | ||
comments.map(async (comment) => await mapToCollborationComment(comment, question)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as on line 10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done too ✅
Changes in this PR:
How to test:
docker compose up --build
)psql "postgresql://inno:hub@localhost:5432/innohub" < ...path_to_dump.sql
psql "postgresql://inno:hub@localhost:5432/innohub"
npm run prisma migrate deploy
in the new branch (this migration should be applied 20241217173509_comment_model)/api/redis/full-refresh
endpointother useful psql commands:
drop schema innohub CASCADE;
SET search_path TO innohub;
Closes #135