Skip to content

Commit

Permalink
fix: Export proposals rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentinchampenois committed Dec 2, 2024
1 parent b6aa45a commit 11c8e6d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ scaleway:
region: fr-par
bucket: <%= Rails.application.secrets.dig(:scaleway, :bucket_name) %>
force_path_style: true
public: true

# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
Expand Down
25 changes: 25 additions & 0 deletions lib/tasks/decidim_app.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ require "decidim_app/k8s/organization_exporter"
require "decidim_app/k8s/manager"

namespace :decidim_app do
desc "Exports proposals from process"
task export_proposals: :environment do
host = "oye.participer.lyon.fr"
pp = Decidim::ParticipatoryProcess.find_by(slug: "bp2022")
component = Decidim::Component.find(1)
proposals = Decidim::Proposals::Proposal.includes(:attachments).where(component: component).state_published
props = proposals.map do |prop|
proposal_h = {}
proposal_h = proposal_h.merge(prop.attributes)
proposal_h[:attachments] = prop.attachments.map do |attc|
Rails.application.routes.url_helpers.rails_blob_url(attc.file.blob, host: host)
end

proposal_h
end

byebug

puts proposal_h
# attc = proposals[0..100].select { |prop| prop.attachments.present? }
# attc.first.attachments.first.file_blob.representation(resize_to_limit: [100, 100]).processed.url

# Find URL : Rails.application.routes.url_helpers.rails_blob_url(ActiveStorage::Blob.find(245), host: "oye.participer.lyon.fr")
end

desc "Setup Decidim-app"
task setup: :environment do
# :nocov:
Expand Down

0 comments on commit 11c8e6d

Please sign in to comment.