The-Enthusiast-404 / git-begin

Git Begin is a Web App to find latest good first issues and start contributing to open source
https://gitbegin.theenthusiast.dev
MIT License
28 stars 15 forks source link

Update Github API query #49

Closed dotslashbit closed 2 weeks ago

dotslashbit commented 2 weeks ago

Currently the api query fetches issues with closed PRs only when hasPR is checked. We need to update the query so that it'll fetch:

If you want to work on this, please comment below. If you need any help, just ping me, I can help you with this, thanks

sanketmn26 commented 2 weeks ago

Checked response data. It is fetching data for has_pull_request = true/false both.

Screenshot (226)

dotslashbit commented 2 weeks ago

Yes but what we want to know is whether it's a open pr or draft or close

Sechorda commented 2 weeks ago

@dotslashbit @sanketmn26 I was able to retrieve the PR state from the graphql query. Are you currently working on this? I May submit a PR here shortly.

image

I also found a response with PR: True and state: null maybe I am doing something wrong here? In this case when I checked, it had no open, draft, or closed PRs for the issue... Is this a github API thing?

image

dotslashbit commented 2 weeks ago

@sanketmn26 @Sechorda

We are using graphql queries and in the docs I found this --> https://docs.github.com/en/graphql/reference/objects#pullrequest

It basically says that every Pr has a closed boolean, so intuitively what I'm thinking is, lets keep the existing queries as is. After fetching all the issues , we can run a query by providing the the Pr object and check its closed value if its closed then we can count it as the issue associated with the current Pr doesn't have any PRs.

Do you get it? If you have any other idea, do let me know

We can take time on this, its not that big of a deal but this will make sure we are giving the best results possible to the user

Sechorda commented 2 weeks ago

@dotslashbit I think I know what you mean, but don't exactly follow. My brain went this way:

Include the PR state in the query, resulting in still only one query. Filter issues base on PR state status with the logic that if it's open, draft, closed, or null (saw some null edge cases) then it returns the issue to the user.

const filteredIssues = issues.filter(issue => { if (!params.hasPullRequests) { return !issue.has_pull_requests; } else { return issue.has_pull_requests && (issue.pr_status === 'OPEN' || issue.pr_status === 'DRAFT' || issue.pr_status === 'CLOSED' || issue.pr_status === null); } });

dotslashbit commented 2 weeks ago

@Sechorda I get it, but is the query working? If it's working then your way is a better solution

Sechorda commented 2 weeks ago

@dotslashbit the PR draft I submitted has a working query and filter based on the requested PR state logic. Double check me though!

Marked PR draft as ready for review

dotslashbit commented 2 weeks ago

@Sechorda sure will do that later, thank you so much

Sechorda commented 2 weeks ago

@dotslashbit woot

sanketmn26 commented 2 weeks ago

@dotslashbit @Sechorda There was a bug in below statement.

Screenshot (227)

We were not importing "nodes" data in query. So when "timelineItems.totalCount > 0 === true". It was throwing error because It could not find "timelineItems.nodes"

Screenshot (228)

Please have a look.

dotslashbit commented 2 weeks ago

@sanketmn26 are you getting an error in the web app or in dev mode. Also have you updated your local setup

sanketmn26 commented 2 weeks ago

@dotslashbit I was getting error in dev mode in local setup. But not after adding nodes in query.

Screenshot (229)

dotslashbit commented 2 weeks ago

@sanketmn26 update your local code, cause I checked on my laptop and it's working perfectly fine

Update your GitHub fork and then do the following

Just do a git pull origin main from your main branch and then run it