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

Validateur NeTEx : polling des résultats #4326

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ptitfred
Copy link
Contributor

@ptitfred ptitfred commented Nov 21, 2024

Cela permet de ne plus bloquer la queue de validation (que ce soit les ressources historisées ou on demand).

Checklist :

  • code non bloquant via des jobs
  • adaptation de /backoffice/jobs pour afficher les jobs en attente
  • tests unitaires
  • tests manuels de OnDemand
  • tests manuels de validation d'une ressource historisée
  • tests manuels de validation concurrente de beaucoup de ressources historisées
require Logger

Logger.info("Starting...")

import Ecto.Query

defmodule Script do
  # for each active dataset, grab all resources with a resource history.
  def query() do
    DB.Dataset.base_query()
    |> DB.Resource.join_dataset_with_resource()
    |> DB.ResourceHistory.join_resource_with_latest_resource_history()
    |> where([resource: r], r.format == "NeTEx")
    |> select([resource_history: rh], rh)
  end

  def validate_resource_history(resource_history_id) do
    %{
      "force_validation" => true,
      "validator" => Atom.to_string(Transport.Validators.NeTEx),
      "resource_history_id" => resource_history_id
    }
    |> Transport.Jobs.ResourceHistoryValidationJob.new()
  end
end

Script.query()
|> DB.Repo.all()
|> Enum.take(20)
|> Enum.map(&(&1.id |> Script.validate_resource_history()))
|> Oban.insert_all()
|> Logger.info()

Voir #4153

@ptitfred ptitfred requested a review from a team as a code owner November 21, 2024 17:06
@ptitfred ptitfred marked this pull request as draft November 21, 2024 17:06
@ptitfred ptitfred mentioned this pull request Nov 25, 2024
17 tasks
@thbar thbar added the NeTEx label Nov 26, 2024
@ptitfred ptitfred force-pushed the netex-validation/polling-of-results branch 7 times, most recently from 22dd49c to 2aa1f2e Compare November 26, 2024 16:39
@ptitfred ptitfred force-pushed the netex-validation/polling-of-results branch from 2aa1f2e to 707dbf2 Compare November 26, 2024 17:40
@ptitfred ptitfred force-pushed the netex-validation/polling-of-results branch from 707dbf2 to 3f6cf5c Compare November 26, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants