goddamnyouryan / coven-api

All the news a programmer needs in once place. http://www.coven.link
8 stars 4 forks source link

Are duplicated position indices normal? #6

Closed jackyliang closed 9 years ago

jackyliang commented 9 years ago
  1. Go to http://api.coven.link/api/v1/posts
  2. Notice that the position value is duplicated across three posts [for example]

    [
    {
    "id":2209554, "position":0, "url":"http://marc.info/?l=openbsd-misc\u0026m=142523501726732", "title":"Improving browser security", "comments":"https://lobste.rs/s/uy21dh/improving_browser_security", "comment_count":6, "external_created_at":"2015-03-01T10:42:20.000-08:00", "created_at":"2015-03-02T01:48:36.654-08:00", "source":"Lobsters", "source_data":{
    "name":"Lobsters", "color":"#96281B", "symbol":"L" } }, {
    "id":2209579, "position":0, "url":"http://www.chris-granger.com/2015/01/26/coding-is-not-the-new-literacy/", "title":"Coding is not the new literacy", "comments":"https://news.ycombinator.com/item?id=9130954", "comment_count":7, "external_created_at":"2015-03-02T00:50:33.000-08:00", "created_at":"2015-03-02T01:48:48.965-08:00", "source":"HackerNews", "source_data":{
    "name":"HackerNews", "color":"#EB974E", "symbol":"Y" } }, {
    "id":2209546, "position":0, "url":"http://www.producthunt.com/l/99dd1ba313/521", "title":"Speaking.io - Brutally honest public speaking advice", "comments":"http://www.producthunt.com/posts/speaking-io", "comment_count":4, "external_created_at":"2015-03-02T00:05:00.000-08:00", "created_at":"2015-03-02T01:48:36.046-08:00", "source":"ProductHunt", "source_data":{
    "name":"ProductHunt", "color":"#DA552F", "symbol":"P" } }, {
    "id":2210034, "position":1, "url":"https://dolphin-emu.org/blog/2015/03/01/dolphin-progress-report-february-2015/", "title":"Dolphin Progress Report: February 2015", "comments":"http://www.reddit.com/r/programming/comments/2xl3ov/dolphin_progress_report_february_2015/", "comment_count":33, "external_created_at":"2015-03-01T11:09:25.000-08:00", "created_at":"2015-03-02T01:48:52.924-08:00", "source":"RProgramming", "source_data":{
    "name":"RProgramming", "color":"#59ABE3", "symbol":"r" } }

  3. Is this normal that the three posts have position:0?

Why I am asking is, I am using the position as an index on displaying the order of posts, and use this index to open posts in the browser, i.e. coven --open 0 to open the article in the 0th index in the browser.

Just find it strange that this index is duplicat. If this is normal, then I'll just reply on my array's index.

EDIT: I can't format Github code blocks..

goddamnyouryan commented 9 years ago

@jackyliang yep these are indeed duplicated on purpose. The position is scoped to the "source". Meaning that HackerNews will have one position 0, Lobsters will, etc. I would have the coven --open 0 open via the position in the array, not on the actual position attribute. Make sense?

jackyliang commented 9 years ago

Yep, that's what I thought, and what I ended up doing: https://github.com/jackyliang/coven-cli

You can try it out.

goddamnyouryan commented 9 years ago

Awesome I will do! I've also added a link to your repo in the readmes of the coven repos.

Thanks so much Jacky. This is great.