Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email for saved searches #1619

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

shanbady
Copy link
Contributor

@shanbady shanbady commented Sep 27, 2024

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/5578

Description (What does it do?)

This PR tweaks the emails sent out for search subscription emails and also activates the search subscription email as a celery task.

Screenshots (if appropriate):

Screenshot 2024-09-27 at 4 33 07 PM Screenshot 2024-09-27 at 4 33 15 PM

How can this be tested?

  1. checkout this branch.
  2. go to RC env var settings in heroku and copy down the following into your local settings:
    MAILGUN_SENDER_DOMAIN
    MAILGUN_KEY
    MAILGUN_FROM_EMAIL
    NOTIFICATION_EMAIL_BACKEND
  3. restart celery via docker compose restart celery
  4. created a saved search subscription that catches learning resources from any provider via the following django shell script (replace user with your own email)
from django.contrib.auth import get_user_model
from learning_resources_search.models import PercolateQuery
from learning_resources_search.api import subscribe_user_to_search_query

User = get_user_model()
migrated_user = User.objects.get(email='[email protected]')
subscribe_user_to_search_query(migrated_user, {"offered_by": ["mitpe", "mitx", "ocw", "see"]}, PercolateQuery.SEARCH_SUBSCRIPTION_TYPE)
  1. Change the "created_on" date locally for a few learning resources. I usually manually do it via this django script:
import datetime
delta = datetime.timedelta(days=1)
since = now_in_utc() - delta


resources = LearningResource.objects.filter(published=True)[50:53]

for resource in resources:
	resource.created_on = since  +  datetime.timedelta(hours=1)
	resource.save()
  1. manually send out subscription emails for search subscriptions (make sure the email you have locally is an inbox you have access to):
from learning_resources_search.models import PercolateQuery
from learning_resources_search.tasks import send_subscription_emails
send_subscription_emails(PercolateQuery.SEARCH_SUBSCRIPTION_TYPE)

@shanbady shanbady changed the title Shanbady/email for saved searches Email for saved searches Sep 27, 2024
@shanbady shanbady marked this pull request as ready for review September 30, 2024 17:25
@shanbady shanbady added Needs Review An open Pull Request that is ready for review and removed Work in Progress labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review An open Pull Request that is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant