Skip to content

Fix taxonomy serialization for export/imports#13857

Merged
alecslupu merged 10 commits intodevelopfrom
fix/taxonomies-import-export
Jan 16, 2025
Merged

Fix taxonomy serialization for export/imports#13857
alecslupu merged 10 commits intodevelopfrom
fix/taxonomies-import-export

Conversation

@microstudi
Copy link
Copy Markdown
Contributor

@microstudi microstudi commented Jan 14, 2025

🎩 What? Why?

There are some problems while serializing taxonomies. Usually, a resource can have multiple taxonomies and the current export method is not well structured. CSV exports are messy too if there are more than one taxonomy.

This PR should fix exports and imports when taxonomies involved

  • Export taxonomies in structured way in JSON
  • Correctly applies exports for CSV files when multiple taxonomies
  • Imports taxonomies in resources (results, proposals)

Notes on taxonomy serialization:

Categories where a one-to-one relation with resources. Taxonomies are one-to-many. As the CSV exporter is not well equiped to deal with arrays, I've decided to transform them to an object with keys => values in this manner:

taxonomies: {
  ids: [123,234],
  123: {
    en: "Taxonomy name"
  },
  234: {
    en: "Another taxonomy name"
  }
}

As is shown, there one key ids containing an array with all the taxonomy IDs for the resource. This comes in handy on imports, as this is the only column used to find the related taxonomies. The rest of the keys are just the ids of the taxonomies pointing to the name of the taxonomy.

📌 Related Issues

Link your PR to an issue

Testing

Describe the best way to test or validate your PR.

📷 Screenshots

JSON Export:
Screenshot from 2025-01-15 11-52-26

CSV Export:
Screenshot from 2025-01-15 11-56-44

♥️ Thank you!

@request-info
Copy link
Copy Markdown

request-info bot commented Jan 14, 2025

It seems like you did not give us much information about what you are trying to do here. We would appreciate it if you could provide us with more info about this issue/PR!

github-actions[bot]
github-actions bot previously approved these changes Jan 14, 2025
github-actions[bot]
github-actions bot previously approved these changes Jan 14, 2025
github-actions[bot]
github-actions bot previously approved these changes Jan 14, 2025
github-actions[bot]
github-actions bot previously approved these changes Jan 15, 2025
github-actions[bot]
github-actions bot previously approved these changes Jan 15, 2025
github-actions[bot]
github-actions bot previously approved these changes Jan 15, 2025
@microstudi microstudi marked this pull request as ready for review January 15, 2025 12:01
github-actions[bot]
github-actions bot previously approved these changes Jan 15, 2025
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.

Looking good by reading the code, but I would simplify a bit.

@microstudi
Copy link
Copy Markdown
Contributor Author

Good points @alecslupu I didn't realize that models where always aliased as resource. Done!

@alecslupu alecslupu self-assigned this Jan 16, 2025
@alecslupu alecslupu added the no-backport Pull Requests that should not be backported label Jan 16, 2025
@alecslupu alecslupu merged commit 45efdc1 into develop Jan 16, 2025
@alecslupu alecslupu deleted the fix/taxonomies-import-export branch January 16, 2025 14:16
greenwoodt pushed a commit to greenwoodt/decidim that referenced this pull request Jan 21, 2025
entantoencuanto added a commit that referenced this pull request Jan 24, 2025
* develop: (30 commits)
  Change hardcoded english in seeds (#13917)
  Allow importing accountability results from a Proposals component (#13817)
  Remove user interests (#13910)
  Move remaining categories from some resources to taxonomies (#13838)
  Fix translation issue on import projects mailer (#13894)
  Update DownloadYourData exports for decidim-debates (#13895)
  Allow admins to publish the questions' answers in surveys (#13786)
  Fix flaky spec in autocomplete (#13901)
  Refine taxonomy filters (part 2) (#13725)
  Fix single attachment with title (#13795)
  Fix incorrect breadcrumb encoding on mobile and tablet (#13891)
  Add string for unpublish survey admin log message (#13890)
  Fix ux meeting date location (#13872)
  New Crowdin updates (#13767)
  Fix deleted user error in schema (#13681)
  Remove assembly types from user interaction (#13881)
  Remove participatory process types from user interaction (#13880)
  Lock concurrent-ruby to 1.3.4 (#13879)
  Fix taxonomy serialization for export/imports (#13857)
  Adjust form upload label changes (#13836)
  ...
antopalidi pushed a commit to openpoke/decidim that referenced this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants