mozillabrasil / sumo_live_helper

Helper Add-on for SUMO forum contributors
https://addons.mozilla.org/firefox/addon/sumo-live-helper-/
Mozilla Public License 2.0
7 stars 8 forks source link

API call is missing parameter #117

Closed WesleyBranton closed 4 years ago

WesleyBranton commented 4 years ago

The SUMO API only returns 20 questions at a time. The problem is with the way that the SUMO API filters out questions.

A question that has an answer posted, is not labelled as is_taken, so it technically passes our criteria. It's included in the API result, but gets thrown out later in the process when we filter out each question based on the number of answers.

For example, the SUMO API will return a list of 20 questions, but maybe 5 of them have at least 1 answer posted to them. Those 5 questions will take up space on the API call result list, but will get discarded later in the process. So only 15 questions will be added to the list.

This leads to a number of problems. For example, if one of those 15 gets marked as solved, it doesn't appear in the next API call. So now there is a free space to fill, which the SUMO API does by pulling the next oldest question, which then gets added to the bottom of the list.

We need to include &num_answers=0 to our API call to ensure that no questions that have answers are displayed on this list. This way all 20 questions returned in the list are ones that don't have answers.

While this is an easy fix, we will need to run an additional check to only include questions from a certain date range. Or else we could get a huge list of old questions. For example, running that filter on the Firefox Enterprise section will return a question all the way from March 2019. It hasn't been answered, so it still appears on the API list, but it's unnecessary to show that on the list.

So, a date check would mean that each section will display either the first 20 questions or questions within a certain time frame.

For example, let's say the time limit is set to 24 hours maximum. If there are 30 questions posted in the past 24 hours, the extension will display the newest 20 questions and exclude the oldest 10 until some of the questions that are newer get answered.

However, if there are only 5 questions in the past 24 hours, the API will see a list of 20, but only the 5 that show up in the last 24 hours will be added to the list display.

The TL;DR of it all is that we are currently hard capped at 20 questions, but we aren't using all 20 question slots because the API call is missing a parameter. But we will need to add a time limit so that old questions get removed outside of X number of days/hours.

It's all easy to implement and I can do it quite easily. I'm just curious about what the time limit should be? The SUMO website has a 24 hours time limit, so should our extension also have the same time limit?

PS: We are currently capped at 20 questions per section, but we could process the next page of questions that's included in the next value of the API call results. But that's another API call to make and complicates cleaning questions from the Storage API. Something we can look into in the future, but it may not be worth it. For now, I'm just sticking with the issue above.

WesleyBranton commented 4 years ago

Looking for input from @dannycolin and @jhonatasrm before I start working on this.

dannycolin commented 4 years ago

It's all easy to implement and I can do it quite easily. I'm just curious about what the time limit should be? The SUMO website has a 24 hours time limit, so should our extension also have the same time limit?

IIUC, the question list is capped to 20 questions all products combined. So, if some products have a longer response time (before someone answer them) than others, wouldn't they be penalized by a 24 hours time limit?

jhonatasrm commented 4 years ago

It's all easy to implement and I can do it quite easily. I'm just curious about what the time limit should be? The SUMO website has a 24 hours time limit, so should our extension also have the same time limit?

I think we can use 24 hours and put some warning about the date range of the questions. Maybe in the future, we can think about an option to change the date range (24,48,72, etc).

WesleyBranton commented 4 years ago

IIUC, the question list is capped to 20 questions all products combined. So, if some products have a longer response time (before someone answer them) than others, wouldn't they be penalized by a 24 hours time limit?

To clarify, nothing is really changing with the question limit. The limit is 20 questions per product, and that's the limit currently as well, so of.

To get the list of questions, the extension sends out a request for each product on the user's watch list. The SUMO website sends a response per product. Each response can only hold 20 questions maximum.

What I'm going to fix is that in the 20 questions currently sent, there are some that have answers on the thread. They don't display on the question list because there is a piece of code in the extension that checks the number of answers in a thread before it decides if it should be printed or not. However, those questions that aren't displayed take up slots in our 20 question limit that the API gives us. By limiting it so that the questions with answers are not included in the API request result, we will get 20 questions per request (product).

That means that if a product has more than 20 questions, the oldest ones won't display because of the cap on that product. But that already happens, but with a lower and inconsistent cap limit.

The reason we need the time limit though is because sections with less activity (like the Firefox Enterprise section) have very old questions listed if you look at the most recent 20 unanswered questions. So old that the last one listed is March 2019 and has been automatically archived for inactivity.

WesleyBranton commented 4 years ago

I think we can use 24 hours and put some warning about the date range of the questions. Maybe in the future, we can think about an option to change the date range (24,48,72, etc).

The 24 hour limit sounds good to me. Where do you think we should add a warning about the limit?

jhonatasrm commented 4 years ago

I think we can use 24 hours and put some warning about the date range of the questions. Maybe in the future, we can think about an option to change the date range (24,48,72, etc).

The 24 hour limit sounds good to me. Where do you think we should add a warning about the limit?

Maybe for more information... but I don't think is really necessary. đŸ™‚

dannycolin commented 4 years ago

To clarify, nothing is really changing with the question limit. The limit is 20 questions per product, and that's the limit currently as well, so of.

Thanks for the clarification. If it's 20 per products then you can ignore my previous comment ;).