-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'production' into rdv-plan-calendar-first
- Loading branch information
Showing
26 changed files
with
220 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
class CronJob::SynchronizeCrm < ApplicationJob | ||
# Base de données "Activation" | ||
# ID récupéré dans l’URL de la page | ||
# Cf: https://developers.notion.com/reference/retrieve-a-database | ||
NOTION_DATABASE_ID = "81a35c7b2490464590a408bbbb78ca2e".freeze | ||
|
||
def perform | ||
return unless ENV["NOTION_API_SECRET"] | ||
|
||
filter = { | ||
and: [ | ||
{ | ||
property: "COMPTE PROD", | ||
url: { | ||
contains: instance_hostname, | ||
}, | ||
}, | ||
], | ||
} | ||
|
||
client.database_query(database_id: NOTION_DATABASE_ID, filter:) do |page| | ||
page.results.each do |notion_page| | ||
rdv_count = Rdv.where(organisation: organisations_ids(notion_page.properties["COMPTE PROD"].url)).count | ||
client.update_page(page_id: notion_page.id, properties: { "NOMBRE DE RDV" => rdv_count }) | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def organisations_ids(account_url) | ||
if account_url.match('territories/(\d+)') | ||
territory_id = account_url.match('territories/(\d+)')[1] | ||
territory = Territory.find(territory_id) | ||
Organisation.where(territory: territory).pluck(:id) | ||
elsif account_url.match('organisations/(\d+)') | ||
[account_url.match('organisations/(\d+)')[1]] | ||
else | ||
raise "Unrecognized account URL: #{account_url}" | ||
end | ||
end | ||
|
||
def instance_hostname | ||
ENV["HOST"].sub("https://", "") | ||
end | ||
|
||
def client | ||
@client ||= Notion::Client.new(token: ENV["NOTION_API_SECRET"]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,8 @@ def modalite | |
end | ||
end | ||
|
||
private | ||
|
||
def return_url_is_authorized | ||
return if return_url.blank? | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
/ locals(organisation: nil) | ||
- if current_agent.unknown_past_rdv_count > 0 && !current_agent.conseiller_numerique? # See https://github.com/betagouv/rdv-solidarites.fr/issues/2245 | ||
li.list-inline-item.fr-mr-2w | ||
= link_to a_renseigner_admin_organisation_rdvs_path(organisation || current_agent.rdvs.a_renseigner.first.organisation_id), class: "btn text-primary-blue link-dsfr" do | ||
span.fr-icon--sm.fr-mr-1v.fr-icon-warning-fill[aria-hidden="true"] | ||
= "#{current_agent.unknown_past_rdv_count} RDV à renseigner" | ||
/ la condition ci-dessous permet de gérer les cas où le compteur en cache unknown_past_rdv_count | ||
/ est supérieur 0 mais qu’on ne retrouve aucun RDV effectivement à renseigner | ||
- organisation_id = organisation&.id || current_agent.rdvs.a_renseigner.first&.organisation_id | ||
- if organisation_id | ||
li.list-inline-item.fr-mr-2w | ||
= link_to a_renseigner_admin_organisation_rdvs_path(organisation_id), class: "btn text-primary-blue link-dsfr" do | ||
span.fr-icon--sm.fr-mr-1v.fr-icon-warning-fill[aria-hidden="true"] | ||
= "#{current_agent.unknown_past_rdv_count} RDV à renseigner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.