Skip to content

feat(case-manager): make GetNextCase relative to the provided case #997

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions repositories/case_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ func (repo *MarbleDbRepository) GetNextCase(ctx context.Context, exec Executor,
OrderBy("boost is null", "created_at", "id").
Limit(1)

if c.AssignedTo == nil {
query = query.Where(
squirrel.And{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed orally earlier: this "pagination" like condition does not exactly match the order that we defined above - also, the index that we created is on "boost is null" (which is similar enough to "boost is not null" but the DB cannot translate) => would be better to replace by "boost is null desc" perhaps. In any case, let me just a moment to review this

squirrel.NotEq{"id": c.Id},
squirrel.GtOrEq{"created_at": c.CreatedAt},
},
)
}

sql, args, err := query.ToSql()
if err != nil {
return "", err
Expand Down