Coder Social home page Coder Social logo

karanjthakkar / showmyprs.com Goto Github PK

View Code? Open in Web Editor NEW
30.0 3.0 4.0 553 KB

See all your Open Source contributions in one place

Home Page: https://showmyprs.com

License: MIT License

JavaScript 100.00%
pull-requests github open-source contributions

showmyprs.com's Introduction

Show My PR's

Motivation 😰

I wanted to create an Open Source section on my website to showcase some of the contributions that I have done over the years. Finding the PR's, sorting them, grouping them was a big pain. I couldnt't find any service that did this already.

Features πŸ’…πŸ»πŸ’₯

  1. Show the actual status of each pull request: open / closed / merged
  2. All your Pull Requests grouped by repositories: /user/<username>
  3. Add ?response_type=json to consume the json response directly
  4. Add ?response_type=iframe to embed the response in an iframe

Implementation notes πŸ™‡πŸ»

  1. Fetch all the pull requests from the github search/issues endpoint

https://api.github.com/search/issues?q=type:pr+author:gaearon+is:public

  1. For each pull request, fetch the repository data (stars/forks)

https://api.github.com/repos/:owner/:repo

Note: The repository data is cached in-memory and is reused between subsequent calls.

  1. The search endpoint returns status as closed even for pull requests that have been merged. So, for each closed pull request, the merge status is fetched using the below endpoint.

https://api.github.com/repos/:owner/:repo/pulls/:number/merge

  1. These pull requests are then grouped based on the repository and then sent to the client.

NOTE: The final response is cached on the server per user in a file ./.cache/<username>. For now, this will be manually purged by me every 24 hours automatically refreshed every 30 minutes using a cron job running via this bash script. Eventually, it should go into some cache like Redis which has its own TTL implementation.

Coming Next πŸ”₯ (Want to help? πŸ‘‡πŸ»)

  • Sorting based on the stars/forks that a repository has (Issue #4)
  • Sorting based on the number of PR's for a repository (Issue #4)
  • Filters based on PR state: Open/Merged/Closed (Issue #3)

Known Issues πŸ’©

  • Maximum limit of 1000 on the total pull requests sent (Issue #10)

Contributing πŸ‘―

  • Make sure you have installed Go and setup your workspace
  • Get the latest code: go get github.com/karanjthakkar/showmyprs.com
  • Start the server: go build && ./showmyprs.com (This requires the GITHUB_TOKEN environment variable. Heres how you can get yours)

If you need help figuring out how to contribute (since its written in Go), hit me up on Twitter or Email. I would love to help you get set up ☺️

Deploying πŸš€

  • Pre-requisite: npm install
  • grunt build deploy: This builds the binary for my Ubuntu linux instance on Amazon EC2 and uploads it along with the web assets via scp.

License

MIT Β© Karan Thakkar

showmyprs.com's People

Contributors

cg-cnu avatar idiotwu avatar karanjthakkar avatar lex111 avatar overtorment avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

showmyprs.com's Issues

Cache the json response for each user

  • Save the json response for each user on disk
  • On every request, check if the user data is available on disk. If yes, render the template using that data.
  • If not, then go with the usual implementation.
  • Also brainstorm whats the best way to burst the cache (delete the disk data essentially)

Filter based on PR status

  1. Send query param to backend for the pr status: ?pr_status=open,closed
  2. Consume this query param in the /user/:username route handler (pr_status can support multiple statuses)
  3. Filter out PR's that don't match this criteria.
  4. Return the data.

Same username but different case breaks cache implementation

Currently when the username karanjthakkar is searched, the cache file of it is created with the name karanjthakkar. However, if the username that is searched becomes KARAnjtHAkkar, then there will be cache miss because it will search for KARAnjtHAkkar.

Allow sorting of the pull requests based on different parameters

  1. Send query param to backend for how to sort. eg: ?sort_by=more_stars
  2. Consume this query param in the /user/:username route handler (sort_by can be one of more_stars, less_stars, more_forks, less_forks, more_prs, less_prs)
  3. Sort the data based on this.
  4. Return the data.

Cant get it running

Just cloned it, maybe Im doing smth wrong, first time Go user :-)

burn@laptop2:~/go/src/github.com/karanjthakkar/showmyprs.com$ go build
# github.com/karanjthakkar/showmyprs.com
./main.go:103: not enough arguments in call to client.Search.Issues
        have (string, *github.SearchOptions)
        want ("context".Context, string, *github.SearchOptions)
./main.go:125: not enough arguments in call to client.Repositories.Get
        have (string, string)
        want ("context".Context, string, string)
./main.go:144: not enough arguments in call to client.PullRequests.IsMerged
        have (string, string, int)
        want ("context".Context, string, string, int)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.