Skip to content

Add Debates to open data zip file#13436

Merged
alecslupu merged 13 commits intodevelopfrom
feature/open-data-debate
Oct 18, 2024
Merged

Add Debates to open data zip file#13436
alecslupu merged 13 commits intodevelopfrom
feature/open-data-debate

Conversation

@andreslucena
Copy link
Copy Markdown
Member

@andreslucena andreslucena commented Sep 26, 2024

🎩 What? Why?

There's a component missing in the open data file: Debates. This PR adds it, and also its comments.

It also adds the Debates resources in the "Export all" feature in the admin panel.

📌 Related Issues

Testing

  1. Click in the "Download Open Data files" in the footer
  2. Open the zip file
  3. Open the localhost-open-data-debates.csv and localhost-open-data-debate_comments.csv

For the "Export all"

  1. Sign in as admin
  2. Go to the admin panel
  3. Go to a Debates component in a participatory space
  4. Click in the "Export all" button
  5. Click in "Debates as CSV" (or any other format)
  6. Go to http://localhost:3000/letter_opener
  7. Open the last email's attachment
  8. See that you have the debates in the format that you've choose

📷 Screenshots

Screenshot of the zip and the CSV import in LibreOffice for debates
Screenshot of the "Export all" dropdown in admin

♥️ Thank you!

github-actions[bot]
github-actions bot previously approved these changes Sep 26, 2024
@andreslucena andreslucena changed the title Add Debates to open data zip file Add Debates to open data zip file Sep 26, 2024
github-actions[bot]
github-actions bot previously approved these changes Sep 26, 2024
github-actions[bot]
github-actions bot previously approved these changes Sep 30, 2024
@andreslucena andreslucena added the project: 2024-api Barcelona Supercomputing Center contract label Sep 30, 2024
github-actions[bot]
github-actions bot previously approved these changes Sep 30, 2024
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debates are presented in export. I only have one things that bothers me, the extra conclusions field. The code suggestion is above.

@alecslupu alecslupu added this to the 0.30.0 milestone Oct 3, 2024
Co-authored-by: Alexandru Emil Lupu <contact@alecslupu.ro>
github-actions[bot]
github-actions bot previously approved these changes Oct 7, 2024
github-actions[bot]
github-actions bot previously approved these changes Oct 7, 2024
github-actions[bot]
github-actions bot previously approved these changes Oct 7, 2024
@andreslucena
Copy link
Copy Markdown
Member Author

@alecslupu I preferred to do the conclusions field differently, see 5437482

I also added the README doc from #13435, as that is already merged into develop

Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check my last comment ?

github-actions[bot]
github-actions bot previously approved these changes Oct 7, 2024
@andreslucena andreslucena requested a review from alecslupu October 7, 2024 19:38
@andreslucena andreslucena dismissed alecslupu’s stale review October 7, 2024 19:38

Ready for another round

Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually found a bug in the Open Data Exporter.
If you have 2 or more debates components then the help sections do not work as intended.

Check the below spec against this PR, and you will notice it fails. Apply the whole patch and see is working properly.

diff --git a/decidim-core/app/services/decidim/open_data_exporter.rb b/decidim-core/app/services/decidim/open_data_exporter.rb
index ccc92113e2..db1f0fb2c9 100644
--- a/decidim-core/app/services/decidim/open_data_exporter.rb
+++ b/decidim-core/app/services/decidim/open_data_exporter.rb
@@ -96,7 +96,7 @@ module Decidim
 
     def get_help_definition(manifest_type, exporter, export_manifest)
       help_definition[manifest_type] = {} if help_definition[manifest_type].nil?
-      help_definition[manifest_type][export_manifest.name] = {}
+      help_definition[manifest_type][export_manifest.name] = {} unless help_definition[manifest_type][export_manifest.name].present?
       exporter.headers_without_locales.each do |header|
         help_definition[manifest_type][export_manifest.name][header] = I18n.t("decidim.open_data.help.#{export_manifest.name}.#{header}")
       end
diff --git a/decidim-debates/spec/services/decidim/open_data_exporter_spec.rb b/decidim-debates/spec/services/decidim/open_data_exporter_spec.rb
index 2c4de3683b..0760b4ba0f 100644
--- a/decidim-debates/spec/services/decidim/open_data_exporter_spec.rb
+++ b/decidim-debates/spec/services/decidim/open_data_exporter_spec.rb
@@ -12,11 +12,18 @@ describe Decidim::OpenDataExporter do
     let(:component) do
       create(:debates_component, organization:, published_at: Time.current)
     end
-    let!(:resource) { create(:debate, :closed, component:) }
+    let!(:resource) { create(:debate,  component:) }
+
+    let(:second_component) do
+      create(:debates_component, organization:, published_at: Time.current)
+    end
+    let!(:second_resource) { create(:debate, :closed, component: second_component) }
+
     let(:resource_title) { "## debates" }
     let(:help_lines) do
       [
-        "* id: The unique identifier of the debate"
+        "* id: The unique identifier of the debate",
+        "* conclusions: The conclusions of the debate if it was closed"
       ]
     end
     let(:unpublished_component) do

github-actions[bot]
github-actions bot previously approved these changes Oct 11, 2024
github-actions[bot]
github-actions bot previously approved these changes Oct 11, 2024
@andreslucena andreslucena dismissed alecslupu’s stale review October 11, 2024 13:02

Ready for another review

Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Merging with codecov failing pipeline.

@alecslupu alecslupu merged commit 25f64af into develop Oct 18, 2024
@alecslupu alecslupu deleted the feature/open-data-debate branch October 18, 2024 20:40
@andreslucena andreslucena added project: 2024-flatfiles Metagov grant and removed project: 2024-api Barcelona Supercomputing Center contract labels Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants