-
Notifications
You must be signed in to change notification settings - Fork 8
Added migration for visits and logic for handling unread comments in … #5295
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
base: master
Are you sure you want to change the base?
Conversation
…grant applications.
|
PR changes has been implemented and re-tested. |
DanThrane
left a 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.
Looks mostly good to me. I have a few small style comments. The bug fix I mentioned is on master now.
core2/pkg/accounting/grants.go
Outdated
| // When GrantApplicationProcess is triggered, we will then compare the last time the user | ||
| // has visited the application with the latest comment of the given application, if the latest comment is greater, | ||
| // then we will set app.Status.HasUnreadComments = true | ||
| func grantUserHasUnreadComments(app *accapi.GrantApplication, username 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.
I would change the name of this function to make it clear that this is not answering a query, but rather attaching the metadata.
Probably something like grantAttachUnreadCommentStatus would do the trick.
core2/pkg/accounting/grants.go
Outdated
| // Getting the latest comment sorted by created at time | ||
| latestCommentTime := app.Status.Comments[0].CreatedAt.Time() | ||
| for _, c := range app.Status.Comments[1:] { | ||
| if c.CreatedAt.Time().After(latestCommentTime) { | ||
| latestCommentTime = c.CreatedAt.Time() | ||
| } | ||
| } |
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 have just pushed a bug fix, which should now mean that comments are in fact guaranteed to be ordered by their creation time. In that case, we can simply replace this with taking the timestamp at the last comment.
core2/pkg/accounting/grants.go
Outdated
| // When GrantApplicationProcess is triggered, we will then compare the last time the user | ||
| // has visited the application with the latest comment of the given application, if the latest comment is greater, | ||
| // then we will set app.Status.HasUnreadComments = true | ||
| func grantUserHasUnreadComments(app *accapi.GrantApplication, username 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.
I would an empty line before this. Go will assume that the comment belongs to the function otherwise. In this case it more belongs to the section.
What has been made:
This is only the backend, no frontend has been implemented yet.
The GrantStatus struct now has the hasUnreadComments,
which the frontend can use for indicating unread comments.