-
Notifications
You must be signed in to change notification settings - Fork 0
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
feature/si-2160-dcn-list-query #61
Conversation
SI-2160 DCN list query
Add a
|
internal/repositories/dcn.go
Outdated
func (r *Repository) GetDCNs(ctx context.Context, first *int, after *string, last *int, before *string, filterBy *gmodel.DCNFilter) (*gmodel.DCNConnection, error) { | ||
var limit int | ||
|
||
if first != nil { |
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.
Doyin has a helper in helpers
that I think we can use.
internal/repositories/dcn.go
Outdated
queryMods = append(queryMods, []qm.QueryMod{ | ||
qm.Limit(limit + 1), | ||
qm.OrderBy(models.DCNColumns.MintedAt + orderBy), | ||
}...) |
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 don't think you need this "wrapper" array, you're just undoing it. See:
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.
Unfortunately you're going to run into cases—unlikely as they may seem—where we have the same mint time but multiple DCNs. I would use the primary key (the node
) to disambiguate. So you're going to have to order by two things and the cursor and ordering is going to be more complicated.
I would look at the privilege pagination stuff for more inspiration.
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.
Here's the general area
models.PrivilegeWhere.SetAt.EQ(afterCursor.SetAt), |
internal/repositories/dcn_test.go
Outdated
o.NoError(err) | ||
} | ||
|
||
// first record (ordered by default, DESC) |
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.
Let's do sub-tests.
The tests here were a bit strange but I think this works. |
Add DCN list query