Skip to content
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

Merged
merged 7 commits into from
Nov 14, 2023
Merged

Conversation

Allyson-English
Copy link
Member

@Allyson-English Allyson-English commented Nov 8, 2023

Add DCN list query

  • return DCNs ordered by Mint Time
  • Clients should be able to filter by DCN owner

Copy link

linear bot commented Nov 8, 2023

SI-2160 DCN list query

Add a dcns list query. This should return DCNs ordered by mint time, descending. Clients should be able to narrow this list down by DCN owner.

{
  dcns(first: 10, filterBy: {owner: "0x4407D41EfBA71a2154E48f312cDfD6e796035b44"}) {
    nodes {
      name
      owner
      mintedAt
    }
  }
}

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 {
Copy link
Member

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.

Comment on lines 110 to 113
queryMods = append(queryMods, []qm.QueryMod{
qm.Limit(limit + 1),
qm.OrderBy(models.DCNColumns.MintedAt + orderBy),
}...)
Copy link
Member

@elffjs elffjs Nov 9, 2023

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:

https://go.dev/play/p/_Vs3xR_u8l0

Copy link
Member

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.

Copy link
Member

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),

o.NoError(err)
}

// first record (ordered by default, DESC)
Copy link
Member

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.

@Allyson-English Allyson-English marked this pull request as ready for review November 13, 2023 17:21
@elffjs elffjs merged commit 875a0e8 into main Nov 14, 2023
2 checks passed
@elffjs
Copy link
Member

elffjs commented Nov 14, 2023

The tests here were a bit strange but I think this works.

@elffjs elffjs deleted the feature/si-2160-dcn-list-query branch November 14, 2023 23:11
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.

None yet

2 participants