Skip to content

Commit

Permalink
Daily snapshot of the stops registry
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitfred committed Jan 29, 2025
1 parent 51e89df commit 6d43eea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions apps/transport/lib/jobs/stops_registry_snapshot_job.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defmodule Transport.Jobs.StopsRegistrySnapshotJob do
@moduledoc """
Job in charge of building a snapshot of the stops registry.
"""

use Oban.Worker, unique: [period: {1, :days}], tags: ["registry"], max_attempts: 3
require Logger

@impl Oban.Worker
def perform(_job) do
file = "#{System.tmp_dir!()}/registre-arrets.csv"

Transport.Registry.Engine.execute(file)
end
end
3 changes: 2 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ oban_prod_crontab = [
{"30 5 * * *", Transport.Jobs.ImportDatasetMonthlyMetricsJob},
{"45 5 * * *", Transport.Jobs.ImportResourceMonthlyMetricsJob},
{"0 8 * * *", Transport.Jobs.WarnUserInactivityJob},
{"*/5 * * * *", Transport.Jobs.UpdateCounterCacheJob}
{"*/5 * * * *", Transport.Jobs.UpdateCounterCacheJob},
{"0 4 * * *", Transport.Jobs.StopsRegistrySnapshotJob}
]

# Make sure that all modules exist
Expand Down

0 comments on commit 6d43eea

Please sign in to comment.