-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deserialisation de provenance_detail
- Loading branch information
Showing
22 changed files
with
117 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 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,15 @@ | ||
# Tâche unique, a passer une fois le champs `solicitations.provenance_detail` créé | ||
class InitSolicitationsProvenanceDetailJob < ApplicationJob | ||
queue_as :low_priority | ||
|
||
def perform | ||
# Correction des solicitations Entreprendre mal affectées | ||
Solicitation.where(cooperation_id: 2).where(provenance_detail: nil).where("solicitations.form_info::json->>'mtm_kwd' LIKE ?", "F%").update_all(cooperation_id: 1) | ||
Solicitation.where(cooperation_id: nil).where(provenance_detail: nil).where("solicitations.form_info::json->>'mtm_kwd' LIKE ?", "F%").update_all(cooperation_id: 1) | ||
|
||
Solicitation.where(provenance_detail: nil).where.not(form_info: {}).find_each do |solicitation| | ||
solicitation.set_provenance_detail | ||
solicitation.save(validate: false) | ||
end | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,18 @@ | ||
class GetProvenanceDetails | ||
# item peut être un user ou une institution | ||
def initialize(cooperation, query) | ||
@cooperation = cooperation | ||
@query = query | ||
end | ||
|
||
def call | ||
return unless @cooperation.with_provenance_details? | ||
return results(entreprendre_provenance_details) if @cooperation.id == 1 | ||
return results(les_aides_provenance_details) if @cooperation.id == 3 | ||
return results(mtee_provenance_details) if @cooperation.id == 4 | ||
return [] unless @cooperation.with_provenance_details? | ||
sanitized_query = Regexp.escape(@query) | ||
provenance_details_list.grep(/#{sanitized_query}/i) | ||
end | ||
|
||
|
||
private | ||
|
||
def results(provenance_details) | ||
provenance_details.grep(/#{@query}/i).map{|s| [s, s] } | ||
end | ||
|
||
# On ne veut que les fiches en F | ||
def entreprendre_provenance_details | ||
@entreprendre_provenance_details ||= @cooperation.solicitations.map{|s| s.mtm_kwd }.compact_blank.uniq | ||
end | ||
|
||
def les_aides_provenance_details | ||
@les_aides_provenance_details ||= @cooperation.solicitations.map{|s| s.origin_title }.compact_blank.uniq | ||
end | ||
|
||
def mtee_provenance_details | ||
@mtee_provenance_details ||= @cooperation.solicitations.map{|s| s.origin_url.gsub("https://mission-transition-ecologique.beta.gouv.fr/", "") }.compact_blank.uniq | ||
def provenance_details_list | ||
@cooperation.solicitations.pluck(:provenance_detail).compact_blank.uniq | ||
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
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
4 changes: 2 additions & 2 deletions
4
app/views/conseiller/cooperations/provenance_detail_autocomplete.html.haml
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,4 +1,4 @@ | ||
.fr-py-1w | ||
- @results.each do |result| | ||
%li.list-group-item{ 'data-autocomplete-value': "#{result.first}", role: 'option' } | ||
= result.first | ||
%li.list-group-item{ 'data-autocomplete-value': "#{result}", role: 'option' } | ||
= result |
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
9 changes: 9 additions & 0 deletions
9
db/migrate/20250123101225_add_provenance_detail_to_solicitations.rb
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,9 @@ | ||
class AddProvenanceDetailToSolicitations < ActiveRecord::Migration[7.2] | ||
def change | ||
add_column :solicitations, :provenance_detail, :string | ||
|
||
up_only do | ||
InitSolicitationsProvenanceDetailJob.perform_later | ||
end | ||
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
Binary file not shown.
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.