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

Upgrade virtual project fields from custom_fields to custom_fields2 #694

Open
hudson-newey opened this issue Nov 26, 2024 · 0 comments
Open
Labels

Comments

@hudson-newey
Copy link
Member

At the moment, the project model is using the deprecated custom_fields property instead of the new custom_fields2

custom_fields: lambda { |item, user|
# do a query for the attributes that may not be in the projection
# instance or id can be nil
fresh_project = item.nil? || item.id.nil? ? nil : Project.find(item.id)
project_hash = {}
project_hash[:site_ids] = fresh_project.nil? ? nil : fresh_project.sites.pluck(:id).flatten
project_hash[:region_ids] = fresh_project.nil? ? nil : fresh_project.regions.pluck(:id).flatten
project_hash[:owner_ids] = fresh_project.nil? ? nil : fresh_project.owners.pluck(:id).flatten
project_hash[:image_urls] = Api::Image.image_urls(fresh_project.image)
project_hash.merge!(item.render_markdown_for_api_for(:description))
# access level for the current user - useful for showing users what their current permission level is
project_hash[:access_level] = Project.access_level(item, user)
[item, project_hash]
},

Because custom_fields doesn't work with projection conditions, project models are not returning the expected result from filter requests that contain projections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant