-
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
draft(issue_match): initial ordering proposal based on entity tags #356
base: main
Are you sure you want to change the base?
Conversation
filterStr := s.getIssueMatchFilterString(filter) | ||
joins := s.getIssueMatchJoins(filter) | ||
cursor := getCursor(filter.Paginated, filterStr, "IM.issuematch_id > ?") | ||
if withOrder { |
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't we just check len(order) > 0
?
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.
True
@@ -120,6 +120,8 @@ func IssueMatchBaseResolver(app app.Heureka, ctx context.Context, filter *model. | |||
|
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 assume line 97 is not required anymore?
issue_match_ids := []*int64{}
for _, issue_match_id := range filter.ID {
filterById, err := ParseCursor(issue_match_id)
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.
Or maybe ParseCursor
should be renamed?
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.
True
After internal discussions, we want to rather use a Builder Like pattern |
filterParameters = append(filterParameters, cursor.Limit) | ||
} | ||
|
||
return stmt, filterParameters, nil | ||
} | ||
|
||
func (s *SqlDatabase) GetAllIssueMatchIds(filter *entity.IssueMatchFilter) ([]int64, error) { | ||
func (s *SqlDatabase) GetAllIssueMatchCursors(filter *entity.IssueMatchFilter, order []entity.Order) ([]string, error) { |
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.
Why do we need this method actually? How does the logic differ from ListIssues ?
Description
This introduces cursor-based ordering for the IssueMatch functionality in the mariadb package. This is an option for an implementaiton of this.
In general for the ordering based on cursors to work we need a cursor that includes all the fields we can order by, e.g.:
"issuematch_id=1, target_remediation_date=2026-01-01, severity=High"
This is needed as we need to build a where statement based on the ordering values e.g. when we want to order first by sevrity, then by target_remeditation_date and then by some other value and then by id it would look like:
( (severity > :severity) OR (severity = :severity ADN target_remediation_date > :trd) OR (severity = :severity ADN target_remediation_date = :trd AND some_other_value>:sov) OR (severity = :severity ADN target_remediation_date = :trd AND some_other_value=:sov AND issuematch_id>:id) )
While the values need to be extracted from the cursor.
This also means we need to be able to generate the cursors accordingly and give cursors for certain list entries back to the caller so that they can use the cursor for pagination. (Getting everything after the cursor)
The here drafted solution does use an approach that marshals and unmarshals cursors into structs based on tags using reflection.
Other potential solutions would be to use a "Builder Pattern" similar to
https://go.dev/play/p/K7aiTQ1zHpW
Another option would be to use JSON as pointers and utilize the already implemented json struct scanning. This would have the disadvantage that it would not support the sql.Null declaration and we could not re-use existing structures.
More details to follow!
What type of PR is this? (check all applicable)
Related Tickets & Documents
#310
Added tests?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Added to documentation?
Checklist