Skip to content
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

ImportGBFSFeedContactEmailJob : remplit organization pour le contact #4345

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions apps/transport/lib/jobs/import_gbfs_feed_contact_email_job.ex
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
defmodule Transport.Jobs.ImportGBFSFeedContactEmailJob do
@moduledoc """
Reuse `feed_contact_email` from GBFS feed.
Reuse `feed_contact_email` from GBFS feeds.

Use these email addresses to find or create a contact and subscribe this contact
to producer subscriptions for this dataset.

When a `feed_contact_point` was previously set and has been removed, we delete old subscriptions.
When a `feed_contact_point` was previously set and changed,
we delete old subscriptions and create new ones.
"""
use Oban.Worker, max_attempts: 3
import Ecto.Query
Expand Down Expand Up @@ -45,7 +46,12 @@ defmodule Transport.Jobs.ImportGBFSFeedContactEmailJob do
contact

nil ->
%{mailing_list_title: contact_title(resource_url), email: feed_contact_email, creation_source: @contact_source}
%{
mailing_list_title: contact_title(resource_url),
email: feed_contact_email,
creation_source: @contact_source,
organization: Transport.GBFSMetadata.operator(resource_url)
}
|> DB.Contact.insert!()
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ defmodule Transport.Test.Transport.Jobs.ImportGBFSFeedContactEmailJobTest do
feed_contact_email: email
})

%DB.Contact{email: ^email, creation_source: :"automation:import_gbfs_feed_contact_email"} =
%DB.Contact{email: ^email, creation_source: :"automation:import_gbfs_feed_contact_email", organization: "Example"} =
contact = DB.Repo.get_by(DB.Contact, mailing_list_title: "Équipe technique GBFS Example")

assert nil == DB.Repo.reload(previous_gbfs_contact_ns)
Expand All @@ -167,7 +167,7 @@ defmodule Transport.Test.Transport.Jobs.ImportGBFSFeedContactEmailJobTest do
)
end)

# Another producer production does not interfere
# Another producer's subscription does not interfere
other_ns =
insert(:notification_subscription,
dataset_id: dataset.id,
Expand Down