paulodiovani / hacktoberrank

Hacktoberfest Rank
https://hacktoberrank-challenge.herokuapp.com/
MIT License
6 stars 17 forks source link

Add a simple database to the back-end #5

Closed paulodiovani closed 5 years ago

paulodiovani commented 5 years ago

Database will be, for start, just a long-term cache to prevent fetch from github api all the time. Redis would be good enough but we could also use Postgress or MongoDB as alternative.

The database should keep a cache of contributions per user and links to pull requests. We can simple store username alongside pull request link to allow search/filter/group by user.

Suggested schema:

user: String (github username) project: String (project name) pull_request: String (pull request link)

arabyalhomsi commented 5 years ago

I claim this! I am going to add Redis

paulodiovani commented 5 years ago

+1 for redis :D

arabyalhomsi commented 5 years ago

https://github.com/arabyalhomsi/hacktoberrank/commit/23fdbba93d039569775be29f90699642d60c8575 This branch is not finsihed yet. I wanted to ask you about which way is the best to store our values in redis. Here, I just store every entry (user and his pull requests) into a redis list. The key of the list is the username and the items are their PRs. It works perfectly, however, the order is not maintained this way. For example, when I fetch entries from redis and show them, they lose their order (from user with highest contributions to lowest). Is it better to store the whole object as a string in a list?

Other than this, we can merge it I think once finished.

@paulodiovani

arabyalhomsi commented 5 years ago

I just pushed another commit to the same branch. I think the approach of savings the individual objects as strings in an ordered list makes the most sense. At least for me! I am not sure how that will affect our ability to do searches and stuff. Waiting to hear your opinion @paulodiovani

paulodiovani commented 5 years ago

I'm not sure... :thinking: we can store in lists or hashes and let the grouping and ordering to javascript (which could overflow server memory), or we can store in sorted sets to allow controlling the sort order.


Another option would be use at least two collections, one for usernames and others for pull requests:

arabyalhomsi commented 5 years ago

I like the structure you suggested. I think by making two collections, we can optimize our db operations. I will try to implement it.

paulodiovani commented 5 years ago

done.