mitodl / mitxonline

BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

Fix Featured Items on Homepage #2232

Closed JenniWhitman closed 1 month ago

JenniWhitman commented 1 month ago

What are the relevant tickets?

Updates https://github.com/mitodl/hq/issues/3017

Description (What does it do?)

Presently, behind a feature flag, the featured items for the homepage are generated and stored in a redis cache. On page load, we check that those courses are still valid and were going from 22 to 7(ish) courses. This is because the end date was not allowed to be null in the cms.models check. I've updated this as well as added a test to determine that we're showing courses when we should (and not when we should not)

How can this be tested?

Have any number of courses that are available to be selected.
Run the create_featured_items management command.
Do a .get on the redis cache to check how many are stored. -

from django.core import caches
caches["redis"].get("CMS_homepage_featured_items")

Load the home page, ensuring that you are in dev/the feature flag is on. Those items in the cache should all appear in the featured carousel.