'marketStress': _make_section(market_stress_section), 'months': _make_section(months_section), 'ofJobNameInDepartement': french.maybe_contract_prefix('de ', "d'", job_name_in_departement), 'ofJobName': french.maybe_contract_prefix('de ', "d'", genderized_job_name), }) campaign.register_campaign( 'imt', campaign.Campaign( mailjet_template='318212', mongo_filters={ 'projects': { '$elemMatch': { 'isIncomplete': { '$ne': True }, }, }, }, get_vars=_get_imt_vars, sender_name="Pascal et l'équipe de Bob", sender_email='*****@*****.**', is_coaching=True, is_big_focus=True, ))
'name': job.name } for job in reorient_jobs], 'loginUrl': campaign.create_logged_url(user.user_id, f'/projet/{project.project_id}'), 'ofJobName': scoring_project.populate_template('%ofJobName'), }) campaign.register_campaign( 'jobbing', campaign.Campaign( mailjet_template='1183675', mongo_filters={ 'projects': { '$elemMatch': { 'isIncomplete': { '$ne': True }, 'openedStrategies.strategyId': 'diploma-free-job', } }, }, get_vars=_get_jobbing_vars, sender_name="Joanna et l'équipe de Bob", sender_email='*****@*****.**', is_coaching=True, is_big_focus=False, ))
campaign.Campaign( mailjet_template='536272', mongo_filters={ '$or': [{ 'employmentStatus': { '$exists': False } }, { 'employmentStatus.seeking': 'STILL_SEEKING' }], 'profile.highestDegree': { '$in': ['UNKNOWN_DEGREE', 'NO_DEGREE', 'CAP_BEP', 'BAC_BACPRO'] }, 'profile.yearOfBirth': { '$gt': datetime.datetime.now().year - 54, '$lt': datetime.datetime.now().year - 18, }, 'registeredAt': { '$gt': _SIX_MONTHS_AGO }, }, get_vars=_open_classrooms_vars, sender_name="Joanna et l'équipe de Bob", sender_email='*****@*****.**', ), } for the_id, the_campaign in _CAMPAIGNS.items(): campaign.register_campaign(the_id, the_campaign)
if city.departement_id != '13': return None if area_type < geo_pb2.DEPARTEMENT: if city.city_id != '13004': return None is_local = True return dict( campaign.get_default_vars(user), **{ 'improveInterviewAdviceUrl': campaign.get_deep_link_advice(user.user_id, project, 'improve-interview'), 'isLocal': campaign.as_template_boolean(is_local), }) campaign.register_campaign( 'salon-arles', campaign.Campaign( mailjet_template='324871', mongo_filters={ 'projects.targetJob.jobGroup.romeId': { '$in': list(_JOB_GROUP_ROME_IDS) }, }, get_vars=_get_vars, sender_name='Joanna de Bob', sender_email='*****@*****.**', ))
"""Compute vars for the "Prepare your application" email.""" project = user.projects[0] deep_link_motivation_email_url = \ campaign.get_deep_link_advice(user.user_id, project, 'motivation-email') return dict(campaign.get_default_coaching_email_vars(user), **{ 'deepLinkMotivationEmailUrl': deep_link_motivation_email_url, 'hasInterviewFrustration': campaign.as_template_boolean(user_pb2.INTERVIEW in user.profile.frustrations), 'hasSelfConfidenceFrustration': campaign.as_template_boolean(user_pb2.SELF_CONFIDENCE in user.profile.frustrations), 'loginUrl': campaign.create_logged_url(user.user_id, f'/projet/{project.project_id}'), }) campaign.register_campaign('prepare-your-application', campaign.Campaign( mailjet_template='1118228', mongo_filters={ 'projects': {'$elemMatch': { 'isIncomplete': {'$ne': True}, }}, }, get_vars=_get_prepare_your_application_vars, sender_name="Joanna et l'équipe de Bob", sender_email='*****@*****.**', is_coaching=True, is_big_focus=True, ))
project = next((p for p in user.projects), project_pb2.Project()) if project.passionate_level > project_pb2.PASSIONATING_JOB: goal = 'trouver un poste qui vous épanouira' elif project.kind == project_pb2.FIND_ANOTHER_JOB: goal = 'décrocher un nouveau poste' else: goal = 'décrocher votre prochain emploi' return dict(campaign.get_default_vars(user), goal=goal) campaign.register_campaign( 'christmas', campaign.Campaign( mailjet_template='279688', mongo_filters={}, get_vars=christmas_vars, sender_name='Joanna de Bob', sender_email='*****@*****.**', )) campaign.register_campaign( 'new-year', campaign.Campaign( mailjet_template='293296', mongo_filters={}, get_vars=new_year_vars, sender_name='Joanna de Bob', sender_email='*****@*****.**', ))
campaign.create_logged_url(user.user_id, f'/projet/{project.project_id}'), 'numTrainings': len(trainings), 'ofJobName': scoring_project.populate_template('%ofJobName'), 'trainings': [json_format.MessageToDict(t) for t in trainings], }) campaign.register_campaign( 'get-diploma', campaign.Campaign( mailjet_template='1130230', mongo_filters={ 'projects': { '$elemMatch': { 'isIncomplete': { '$ne': True }, 'openedStrategies.strategyId': 'get-diploma', } }, }, get_vars=_get_find_diploma_vars, sender_name="Joanna et l'équipe de Bob", sender_email='*****@*****.**', is_coaching=True, is_big_focus=True, ))
else: has_experience = '' deep_link_advice_url = \ campaign.get_deep_link_advice(user.user_id, project, 'improve-resume') or \ campaign.get_deep_link_advice(user.user_id, project, 'fresh-resume') auth_token = parse.quote(auth.create_token(user.user_id, is_using_timestamp=True)) return dict(campaign.get_default_coaching_email_vars(user), **{ 'deepLinkAdviceUrl': deep_link_advice_url, 'hasExperience': has_experience, 'isSeptember': campaign.as_template_boolean(now.month == 9), 'loginUrl': f'{campaign.BASE_URL}?userId={user.user_id}&authToken={auth_token}', }) campaign.register_campaign('improve-cv', campaign.Campaign( mailjet_template='980269', mongo_filters={ 'profile.frustrations': 'RESUME', 'projects': {'$elemMatch': { 'isIncomplete': {'$ne': True}, }}, }, get_vars=_get_improve_cv_vars, sender_name="Joanna et l'équipe de Bob", sender_email='*****@*****.**', is_coaching=True, is_big_focus=True, ))
_make_section(months_section), 'ofJobNameInDepartement': french.maybe_contract_prefix('de ', "d'", job_name_in_departement), 'ofJobName': french.maybe_contract_prefix('de ', "d'", genderized_job_name), 'showPs': campaign.as_template_boolean( _can_go_to_arles_hotellerie_event(rome_id, project.mobility)), 'statusUpdateUrl': campaign.get_status_update_link(user.user_id, user.profile), }) campaign.register_campaign( 'imt', campaign.Campaign( mailjet_template='318212', mongo_filters={ 'projects': { '$elemMatch': { 'isIncomplete': { '$exists': False }, }, }, }, get_vars=imt_vars, sender_name='Pascal de Bob', sender_email='*****@*****.**', ))
'jobGroupInDepartement': '{} {}'.format( french.lower_first_letter(project.target_job.job_group.name), geo.get_in_a_departement_text( database, project.mobility.city.departement_id)), 'networkApplicationPercentage': network_application_importance, }) campaign.register_campaign( 'focus-network', campaign.Campaign( mailjet_template='205970', mongo_filters={ 'projects.networkEstimate': 1, }, get_vars=network_vars, sender_name='Margaux de Bob', sender_email='*****@*****.**', )) campaign.register_campaign( 'network-plus', campaign.Campaign( mailjet_template='300528', mongo_filters={ 'projects': { '$exists': True }, 'projects.networkEstimate': {
f'{job_group_name} {in_departement}', 'networkApplicationPercentage': network_application_importance, }) campaign.register_campaign( 'focus-network', campaign.Campaign( mailjet_template='205970', mongo_filters={ 'projects': { '$elemMatch': { 'networkEstimate': 1, 'isIncomplete': { '$ne': True }, } }, }, get_vars=_get_network_vars, sender_name="Joanna et l'équipe de Bob", sender_email='*****@*****.**', is_coaching=True, is_big_focus=True, )) campaign.register_campaign( 'network-plus', campaign.Campaign( mailjet_template='300528', mongo_filters={
'projects': { '$exists': True }, 'projects.isIncomplete': { '$ne': True }, 'registeredAt': { '$gt': '2018-01-01' }, }, get_vars=_get_nps_vars, sender_name='Bob', sender_email='*****@*****.**', ) campaign.register_campaign(_CAMPAIGN_ID, _NPS_CAMPAIGN) def _send_reports(count: int, errors: List[str]) -> None: logging.warning('%d emails sent.', count) report.notify_slack( f"Report for NPS blast: I've sent {count:d} emails (with {len(errors):d} errors)." ) # TODO(pascal): Move to mail_blast module. def main(now: datetime.datetime, days_before_sending: str) -> None: """Send an email to users that signed up more than n days ago list of users.""" stats_db, user_db, unused_eval_db = mongo.get_connections_from_env()
campaign.register_campaign( 'account-deletion-notice', campaign.Campaign( mailjet_template='1088068', mongo_filters={ # User hasn't been on Bob for two years. 'registeredAt': { '$lt': _TWO_YEARS_AGO_STRING }, 'requestedByUserAtDate': { '$not': { '$gt': _TWO_YEARS_AGO_STRING } }, # User hasn't read any email we sent to them in the last two years. 'emailsSent': { '$not': { '$elemMatch': { 'sentAt': { '$gt': _TWO_YEARS_AGO_STRING }, 'status': { '$in': ['EMAIL_SENT_OPENED', 'EMAIL_SENT_CLICKED'] }, } } }, }, get_vars=_account_deletion_notice_vars, sender_name="Joanna et l'équipe de Bob", sender_email='*****@*****.**', ))