Skip to content

[BE] Can we improve the Programming languages sync script #1203

@alexanmtz

Description

@alexanmtz

✏️ Summary

Improve and optimize our sync for programming languages

📋 Description

We have a script for syncing the GitHub programming languages for a project used for the bounty filters: https://github.com/worknenjoy/gitpay/blob/master/scripts/update_projects_programming_languages.js

We want to optimize this script so we avoid the Github API limit exceeded and have a better handle of the programming languages. Currently, we are clearing all and re-associating again.

You could maybe use a header to be smarter about these verifications and know if this was already synced so we don't hit the limit.

A good extra would be when the GitHub API limit is exceeded. We would get the response for how long we will be blocked, and rerun the script after that interval.

You should write automated tests for it.

🔍 Steps to Reproduce (or trigger)

  1. Check out the project repository: https://github.com/worknenjoy/gitpay
  2. Follow our README file to setup the project locally
  3. Import at least one issue (if you import many, you will probably see the limit when executing the script)
  4. Run the script node ./scripts/update_projects_programming_languages.js

✅ Expected Behavior

  1. The script should sync programming languages with the issues imported to Gitpay and display on our filters
  2. The script should not make unnecessary calls or clear the Programming languages and associate again, it should check
  3. It would be nice if we hit the API limit, and we get from the response the blocked time and rerun the script when we can call the API again

🛠️ Stack Affected

Node.js

📜 Relevant Logs / Payload

API limit message

https://github.com/worknenjoy/gitpay/blob/master/test/data/github.issue.error.js

    { "message": "API rate limit exceeded for 87.52.110.50. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.) If you reach out to GitHub Support for help, please include the request ID FF0B:15FEB:9CD277E:9D9D116:66193B8E.", "documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api" }

https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#checking-the-status-of-your-rate-limit

The headers will contain

x-ratelimit-reset - The time at which the current rate limit window resets, in UTC epoch seconds

💰 Is there a bounty for this issue?

No

💵 Bounty Amount (if any)

No bounty for this issue

📜 Bounty Details (if applicable)

There's no Bounty for this issue.

This issue is part of the Only Dust Hackathon: https://onlydust.notion.site/May-28th-Open-Source-Hackathon-1f244b682a80801890e5fda15b779746

Metadata

Metadata

Labels

APItasks that deals with third-party api'sODHack14help wantednode.jsTaks that requires node.js knowledge

Projects

Status

To do

Relationships

None yet

Development

No branches or pull requests

Issue actions