-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
sync email subscriber and profiles keywords field #4474
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4474 +/- ##
==========================================
- Coverage 30.08% 30.03% -0.06%
==========================================
Files 209 210 +1
Lines 16850 16881 +31
Branches 2267 2275 +8
==========================================
Hits 5070 5070
- Misses 11582 11613 +31
Partials 198 198
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #4474 +/- ##
==========================================
- Coverage 30.17% 30.12% -0.05%
==========================================
Files 209 210 +1
Lines 16886 16914 +28
Branches 2278 2285 +7
==========================================
Hits 5095 5095
- Misses 11594 11622 +28
Partials 197 197
Continue to review full report at Codecov.
|
c371c8b
to
b58816e
Compare
its not clear to me that a cronjob is the right place for this... maybe the profile <> emailsubscriber sync could happpen in a presave hook. |
I was thinking more of a post_save hook in both the models. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question but other than that looks good
es = EmailSubscriber.objects.filter(email=profile.email).exclude(keywords=[]).first() | ||
if es: | ||
print("2", es.keywords, profile.handle) | ||
profile.keywords = es.keywords |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to append these keywords rather than overwrite them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just addressed dan's feedback |
profile.save() | ||
|
||
# pull keywords by emailsubscriber into profile | ||
for profile in Profile.objects.filter(keywords=[]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are iterating over the profiles that don't have any keywords, but the for loop above assigns keywords to each profile that lacks them if there is a search history object for that user. In this loop, we are combining the email subscriber keywords with the profile keywords, but we are only iterating over profiles that have no keywords.
I think we need to combine the two for profile in Profile.objects.filter(keywords=[]):
loops so we can get both search history and email subscriber keywords applied. In the current code, adding the search history keywords to a profile essentially skips adding email subscriber keywords to that same profile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
sync email subscriber and profiles keywords field per #4424
Refers/Fixes
#4424
Testing
tested on my local