Skip to content

Conversation

@vushu
Copy link
Contributor

@vushu vushu commented Jan 28, 2026

What has been made:

  • Added migration for tracking user visits on grant applications
  • Added logic for handling the unread comments
  • Tested using different users.

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.

type GrantStatus struct {
	OverallState      GrantApplicationState     `json:"overallState"`
	StateBreakdown    []GrantGiverApprovalState `json:"stateBreakdown"`
	Comments          []GrantComment            `json:"comments"`
	Revisions         []GrantRevision           `json:"revisions"`
	ProjectTitle      util.Option[string]       `json:"projectTitle"`
	ProjectPI         string                    `json:"projectPI"`
	HasUnreadComments bool                      `json:"hasUnreadComments"`
}

@vushu vushu requested a review from DanThrane January 28, 2026 13:18
@vushu
Copy link
Contributor Author

vushu commented Feb 2, 2026

PR changes has been implemented and re-tested.

@vushu vushu requested a review from DanThrane February 2, 2026 10:27
Copy link
Collaborator

@DanThrane DanThrane left a 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.

// 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) {
Copy link
Collaborator

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.

Comment on lines 1134 to 1140
// 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()
}
}
Copy link
Collaborator

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.

// 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) {
Copy link
Collaborator

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.

@vushu vushu requested a review from DanThrane February 3, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants