kpagacz/wiki-on-fire

Create http layer for getting articles

Closed this issue · 5 comments

Function that will get articles from endpoint.
Arguments: first index, number of articles
Should return array of objects with properites:

  • id
  • topic
  • dateAdded
  • lastEdition
  • numberOfViewers (last week)
  • numberOfEditions (last week)

Konrad EDIT: I have another vision for this. I would like the backend endpoint to be paginated, so I would like it to return a certain page, given the number of articles per page specified and the starting index of the articles. So the index would possibly be in the middle of the page.

I also imagine that this function should return more than just the array of objects. It should return the page number as well as the number of the last page that backend can return given the number of articles per page. So an object with a structure like this:
{
page: ,
total_pages: ,
items: [ ],
}

Blocked by: #185

I am also unsure about feasibility of lastEdition and dateAdded at this time. Might have to deal with less info for now.

I envision it to use a modified get articles endpoint.

So the goal of this task would be also to modify the get articles endpoint (possibly create another one?) to support the information required in this issue as well as support pagination.

Another question I see for this: considering we want the top views as well as top edits, we need to consider the use case of this endpoint.

Seems like in the actual application we only want the articles with lots of views and edits first. Specifically I would focus on views first. Then, I fail to see the usefulness of data added in there as well as last edition. This data does not matter since everything we want to show people at this time is the topic, link views and maybe edits in the future.

All in all, this endpoint probably should search through the topViews table, moreover it should focus only on items from the last week or another arbitrary time frame (for now), calculate the results and then return them. We don't need anything besides the topic, link and the views currently.

I also imagine that this function should return more than just the array of objects. It should return the page number as well as the number of the last page that backend can return given the number of articles per page. So an object with a structure like this: { page: , total_pages: , items: [ ], }

Yes, this endpoint response sounds better, but 'page' is probably not needed here.
We should pass number of page from frontend