You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a comment in the function that says to improve the stop condition when there are fixed articles (for this categories, the needed value would be less than the hardcoded value of 10).
DONE iterate over ArticleRel.edition.date_published ranges, this way, in a very populated environment (the most probable scenario) we can achieve goals in the first range iteration, that would be much faster than execute the whole join with no date restriction.
DONE Another improvement: the most inner for iterates over all categories, this can be easily improved into an iteration over only those categories that need more articles, pseudo:
categories_to_fill = settings.CORE...
if categories_to_fill:
...
for edition in ...
for ar in ...
if categories_to_fill:
article = ...
for cat in categories_to_fill:
if article matches criteria to enter:
append the article
if now this cat is full:
remove it from the categories_to_fill list
else:
stop = True
break
if stop:
break
DONE But also there is another good thing to do there: when the home is not fully-filled, is much probable that there aren't more articles than this number, so, we can previously count them (new Category method) to know which is the new max value and also decrease the "needed" value to this counter (in a per-category way), this avoids the unnecessary loop until the oldest edition that will not find anything.
Of course this improvements not cover all the scenarios that can run the "complete" loop, but minimizes them in a very good way.
DONEimportant PD: the hardcoded value "11" should also be reviewed, because we need 10, the value is used to iterate over a range that could be easily fixed later with a simple "+1". check, fix and test this improvement before doing anything else.
The text was updated successfully, but these errors were encountered:
TODO: check when there are 2 articles and then the first one is "unpublished", it seems that its place is filled again with the article left and causes a duplication (maybe a "cleaning" is needed after the fill algorithm at the end of the function)
There is a comment in the function that says to improve the stop condition when there are fixed articles (for this categories, the needed value would be less than the hardcoded value of 10).
DONE iterate over ArticleRel.edition.date_published ranges, this way, in a very populated environment (the most probable scenario) we can achieve goals in the first range iteration, that would be much faster than execute the whole join with no date restriction.
DONE Another improvement: the most inner for iterates over all categories, this can be easily improved into an iteration over only those categories that need more articles, pseudo:
DONE But also there is another good thing to do there: when the home is not fully-filled, is much probable that there aren't more articles than this number, so, we can previously count them (new Category method) to know which is the new max value and also decrease the "needed" value to this counter (in a per-category way), this avoids the unnecessary loop until the oldest edition that will not find anything.
Of course this improvements not cover all the scenarios that can run the "complete" loop, but minimizes them in a very good way.
DONE important PD: the hardcoded value "11" should also be reviewed, because we need 10, the value is used to iterate over a range that could be easily fixed later with a simple "+1". check, fix and test this improvement before doing anything else.
The text was updated successfully, but these errors were encountered: