Merge pull request #5337 from betagouv/fix-broken-empty-demandes-screen

fix demandes adapter when no demandes
This commit is contained in:
Keirua 2020-07-07 10:04:41 +02:00 committed by GitHub
commit 11b9847a33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,17 +6,23 @@ class Pipedrive::PersonAdapter
PIPEDRIVE_ROBOT_ID = '11381160'
def self.get_demandes_from_persons_owned_by_robot
Pipedrive::API.get_persons_owned_by_user(PIPEDRIVE_ROBOT_ID).map do |datum|
{
person_id: datum['id'],
nom: datum['name'],
poste: datum[PIPEDRIVE_POSTE_ATTRIBUTE_ID],
email: datum.dig('email', 0, 'value'),
tel: datum.dig('phone', 0, 'value'),
organisation: datum['org_name'],
nb_dossiers: datum[PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID],
deadline: datum[PIPEDRIVE_DEADLINE_ATTRIBUTE_ID]
}
demandes = Pipedrive::API.get_persons_owned_by_user(PIPEDRIVE_ROBOT_ID)
if demandes.present?
demandes.map do |datum|
{
person_id: datum['id'],
nom: datum['name'],
poste: datum[PIPEDRIVE_POSTE_ATTRIBUTE_ID],
email: datum.dig('email', 0, 'value'),
tel: datum.dig('phone', 0, 'value'),
organisation: datum['org_name'],
nb_dossiers: datum[PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID],
deadline: datum[PIPEDRIVE_DEADLINE_ATTRIBUTE_ID]
}
end
else
[]
end
end