Skip to content

feat: async enumerable and lazy paging#128

Merged
Insomniak47 merged 17 commits intomainfrom
feat/async-enumerable-and-lazy-paging
Dec 24, 2021
Merged

feat: async enumerable and lazy paging#128
Insomniak47 merged 17 commits intomainfrom
feat/async-enumerable-and-lazy-paging

Conversation

@Insomniak47
Copy link
Member

@Insomniak47 Insomniak47 commented Dec 20, 2021

Also fixed a bug in details if no checks were present.

Also added a few small sort keys on properties that already exist

@Insomniak47 Insomniak47 marked this pull request as ready for review December 21, 2021 15:05
throw new ArgumentOutOfRangeException(nameof(pageSize), "Must be between 1 and 100");

PageSize = pageSize;
EndCursor = endCursor;
Copy link
Member

Choose a reason for hiding this comment

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

I'd have to look at docs again but I think end-cursor is the field that the cursor value comes to us in, in this case it's the cursor we want to start at. I can't imagine we'd do a query from a cursor other than the end-cursor of the previous page but there might be a more context-appropriate name.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll noodle on that

Copy link
Member

Choose a reason for hiding this comment

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

A few options come to mind (in vaguely the order of my preference):

after
nextPage
page
pageCursor
nextPageCursor
afterCursor
nextCursor
startCursor

They all have a bit of a stink to them, though endCursor is my least favorite by a small margin since it's named after the source of the value rather than for what the field is.

I like after the most because that's the name of the query field it populates. Next to that nextPage seems like the best description of what the value means.

I don't really like startCursor though I'm not sure why. It is the cursor that specifies where to start so it makes sense; maybe I just don't like that the response we got it from and the response we're expecting will (or at least could) have startCursor values and neither one will match the value of the property.

The rest all seem like okay things to call the thing we know we're talking about, but I don't think they'd be as self-explanatory as good names can be.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do after

Copy link
Member Author

Choose a reason for hiding this comment

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

done

{
if (value.ReviewThreads.PageInfo.HasNextPage)
{
prsWithMoreThreads.Add(value);
Copy link
Member

Choose a reason for hiding this comment

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

Now that we’re yielding the other ones out I think prs is the same collection as prs with more threads. We can yield out the completed ones in each iteration of the paging loop and ditch the second collection.

Copy link
Member

Choose a reason for hiding this comment

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

Actual we can merge the loop behaviours too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Still wanna chat about this but wanna get it in in a different PR?

return new GraphQLHttpRequest(PRSearch.Search.GenerateInvolves(searchParams));
if (response.Errors != null)
{
Console.WriteLine($"ERROR: {string.Join('\n', response.Errors.Select(x => x.Message))}");
Copy link
Member

Choose a reason for hiding this comment

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

Logger?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have one registered atm. Was going to but want to chat with you about what we went with. Ideally something minimal

@Insomniak47 Insomniak47 merged commit 44a0620 into main Dec 24, 2021
@Insomniak47 Insomniak47 deleted the feat/async-enumerable-and-lazy-paging branch December 24, 2021 01:22
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.

2 participants