Closed ujjwalagrawal17 closed 3 years ago
@ujjwalagrawal17 I would like to work on this issue. KIndly assign this to me.
@anuradhajha99 feel free to start working on it. We will use this in the Android app after it's ready.
@ujjwalagrawal17 KIndly help me if I am wrong. But I visited the website https://outreachdashboard.wmflabs.org/courses/WMFr/EDITATHONS_2017/uploads and the uploads section already had the pagination. Can you kindly explain how should I start with the issue? Thank you very much.
I guess the support in web version is added but in https://outreachdashboard.wmflabs.org/courses/WMFr/EDITATHONS_2017/uploads.json API it's not added. We need to add the required parameters to make it work.
We are consuming the API from Android App and in some courses we are getting very slow response.
@ujjwalagrawal17 Thank you very much. however, can you give me an idea of how should I start with the issue, what steps should I start taking, what files do I need to change? It will be very helpful.
@ragesoss might be able to help you in that. I am not familiar with the website codebase.
@ragesoss Can you please guide me through the following issue? Also, Thank you very much @ujjwalagrawal17 for helping.
The uploads endpoint is CoursesController#uploads
, which basically just finds the course and then immediately renders the corresponding view, app/views/courses/uploads.json.jbuilder
.
The most similar place where you can find an example of pagination already in use is CampaignsController
, which sets the page from the query parameters, and then uses the will_paginate
gem to get the page-based query results in the 'articles' and 'programs' views. The same strategy should work here, but for CoursesController#uploads
we would need to either only paginate if the page
param is there (so that the web version maintains the current behavior), or also update the website frontend to use the pagination. Currently, we just have client-side pagination on the web, so it requests and stores the full set of uploads data, and then only renders one page at a time but does not make additional requests to the server.
@ragesoss Can you please navigate me to the CampaignsController code to understand the context? I am having some difficulty in understanding the codebase.
CampaignsController is in app/controllers/campaigns_controller.rb
. It's responsible for handling web requests to main 'campaigns' views, such as https://dashboard.wikiedu.org/campaigns/fall_2018/programs
If you're unfamiliar with Ruby on Rails, I suggest starting by exploring the Rails documentation a bit to see how models, views, and controllers interact.
@ragesoss we have to find the page
param from the URL and use the will_paginate gem if the param is present? am I following the correct way? Thank you for the feedback.
Yes, I think so.
Going by the campaign_controller.rb
, I came across various dependencies, What are the required dependencies to make the course-controller
, that will extract the URL
and then the page param from the dependencies?
Rails provides all request parameters via params
, which is basically just a hash.
This controller uses the set_page
method to set an instance variable from that param, and the instance variable can then be used in the view template that gets rendered.
Am I supposed to make another view for the uploads, just like article
and programs
in the campaign controller, because I have set the params of the page
in course-controller
but I cannot find uploads.haml which is used to render as a view?
For courses controller, it uses a json jbuilder view template instead of an html haml template. This app/view/courses/uploads.json.builder
.
Hi, @ragesoss. Was this issue successfully solved?? if not I would love to get right on itas my first contribution.
@tafodinho I had various problems while solving the following issue. You can refer to the pull requests that I made, to understand the errors. Thank you for taking the following issue. I am sorry I could not work due to the lack of knowledge and time.
okay @ANURADHAJHA99 let me take a look right now
hi @tafodinho are you still working on this? @ragesoss is the issue still open?
Yes, it's still open.
@ragesoss okay I'm starting to work on it
I'm still working on it. Just getting to know the codebase and setting up the development environment. Reached till populating the database.
@ragesoss I have an issue My http://localhost:3000/courses/ab/ab/uploads.json returns {"course":{"uploads":[]}} Idk how to populate data in upload array to check my pagination Can you please tell me how to populate data in this uploads array in the database?
@ujjwalagrawal17 @ragesoss Can you please tell me how many entries we want on a page? For 10 entries, the INFO says it completed in 10ms and for 193 entries, it says it completed in 40ms
I think 10 is fine for android because android has less screen space (shorter screen size).
Yes 10 is fine. If you can add another variable to make it configurable, it will be great.
Sure, I can add another variable.
I added another variable and updated the PR. Can you please check if it's working fine as required. Also, it failed Travis build with the first commit. I can't figure out why.
The build problem was unrelated (and now fixed on master)... it looks like this doesn't break any tests that weren't already broken. It's probably ready to go once it has a spec to exercise the pagination functionality.
Closing this, since the phone app isn't under activity development.
in Some courses like https://outreachdashboard.wmflabs.org/courses/WMFr/EDITATHONS_2017/uploads.json ,the uploads API is taking a lot of time to give response [this course has around 500 images]. We can implement pagination in the API to give results by using parameter page_number.