Request badges for new members #7
Conversation
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.
Je me demande s'il est réellement nécessaire d'ajouter la dépendance à redis
et à quelle point elle est lourde, mais je ne m'y connais pas suffisamment sur le sujet dans l'immédiat et n'ai pas le temps de rechercher pour avoir un avis.
C'est très enthousiasmant en tous cas !!
data/body_badge.txt
Outdated
@@ -0,0 +1,6 @@ | |||
Bonjour, | |||
|
|||
Serait-il possible de fournir un badge à {{author.fullname}}, qui nous rejoint en tant que {{author.employer}} jusqu'au {{author.end}} au sein de l’incubateur ? |
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.
Au vu du format de {{author.employer}}
, une formulation de type « par un contrat {{author.employer}}
» me semblerait plus adaptée que « en tant que » (dinsic
, independent/octo
, service/octo
…).
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.
Je pensais réaliser un mapping, style formulations[author.employer.split('/')[0]]
et ça va exiger un brin de refactoring du code qui établit le contexte pour Liquid...
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.
Oui, on peut changer le code… ou sinon on peut juste changer le texte, non ? 😉
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.
En fait il y a une étape intermédiaire: l'API à l'heure actuelle n'expose pas employer
(oops)
Je démarre une PR sur beta.gouv.fr avec une montée de version en 1.2
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.
Ou alors on peut considérer que ce n'est pas important de savoir en tant que quoi les gens nous rejoignent?
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.
Tu as raison, et j'aurais dû t'écouter plus tôt. ;)
data/body_badge.txt
Outdated
Serait-il possible de fournir un badge à {{author.fullname}}, qui nous rejoint en tant que {{author.employer}} jusqu'au {{author.end}} au sein de l’incubateur ? | ||
|
||
Bonne journée, | ||
L'Incubateur |
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.
« Le secrétariat de l'incubateur » ?
J'aime beaucoup l'idée du secrétariat robotique…
Ça n’avait pas été ajouté pour le fun, tu dois préciser si c’est presta ou non, c’est important pour leur registre. On peut tenter sans, mais c’était une demande explicite côté administration.
|
Argh. Je vais revert le commit précédent. |
Le filesystem de Heroku est éphémère et ne permet pas d'écrire au disque, donc ça rend obligatoire d'écrire à une base de données qui ne soit pas server-less. Lorsque le job-to-be-done est de « ne pas être harcelé·e (en tant que personne responsable de faire de badges) par des demandes (répétées) de ceux-ci », il est besoin IMHO de savoir si l'email a été déjà envoyé avant. Ceci dit, j'imagine rapidement les solutions :
|
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.
- Essaie de renommer
BadgeBoy
pour le rendre gender-less - Essaie de séparer plus clairement la logique de service (envoyer l'email) de de modèle (écrire et lire à la base de données). Bien que séparer en deux classes ne me semple pas forcement nécessaire, au moins je séparerait les méthodes.
lib/betagouvbot/badgeboy.rb
Outdated
.each { |member| maybe_request_badge(member) } | ||
end | ||
|
||
def maybe_request_badge(author) |
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.
This is a policy method, should be written as, for example, badge_requested?(author)
lib/betagouvbot/badgeboy.rb
Outdated
members | ||
.map(&:with_indifferent_access) | ||
.select { |member| member[:based] == 'dinsic' } | ||
.each { |member| maybe_request_badge(member) } |
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.
request_badge(member) unless badge_requested?(member)
lib/betagouvbot/badgeboy.rb
Outdated
mailer.post(email) | ||
end | ||
|
||
def state_storage |
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.
Or just storage
lib/betagouvbot/webhook.rb
Outdated
@@ -24,6 +25,9 @@ class Webhook < Sinatra::Base | |||
# Send reminders (if any) | |||
Mailer.(schedule, RULES) | |||
|
|||
# Request badges (if any) | |||
BadgeBoy.(members) |
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.
Or girl
spec/betagouvbot/badgeboy_spec.rb
Outdated
|
||
it 'requests a badge for new members' do | ||
described_class.(authors) | ||
expect(described_class).to have_received(:request_badge).once |
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.
Or (haven't tried) :
expect(described_class).to have_received(:request_badge).with(ann).once
Before merging:
|
Current behaviour:
office
set todinsic
employer
in the email sent to DINSIC secretariatThis may be good enough to go live. Future enhancements will include a better representation of the
employer
field, and perhaps explicit handling of contract renewals.