noosfero | WIP: Custom forms graphs (!1597)

Rodrigo Souto gitlab at mg.gitlab.com
Mon Aug 20 18:01:18 BRT 2018


Rodrigo Souto commented on a discussion on plugins/custom_forms/lib/custom_forms_plugin/graph.rb:

>    end
>  
> -  alias select_answers radio_answers
> -  alias multiple_select_answers check_box_answers
> +  def get_text_fields
> +    @form.fields
> +         .joins("INNER JOIN custom_forms_plugin_answers as ans ON ans.field_id = custom_forms_plugin_fields.id
> +                 INNER JOIN custom_forms_plugin_submissions as s ON s.id = ans.submission_id")
> +         .group("custom_forms_plugin_fields.id, custom_forms_plugin_fields.name")
> +         .select("custom_forms_plugin_fields.id as id,
> +                   custom_forms_plugin_fields.name as field_name,
> +                   STRING_AGG(ans.value, ',') as answers,
> +                   STRING_AGG(s.author_name, ',') as users,
> +                   custom_forms_plugin_fields.show_as as show_as,
> +                   STRING_AGG(ans.imported::text, ',') as imported")
> +         .where("custom_forms_plugin_fields.type = 'CustomFormsPlugin::TextField'")

I think this works. I'm just not sure why you needed the STRING_AGG on all those fields. Can you explain me?

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/noosfero/noosfero/merge_requests/1597#note_95699513
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180820/d3c4357f/attachment.html>


More information about the Noosfero-dev mailing list