noosfero | WIP: Custom forms graphs (!1597)

Álax Alves gitlab at mg.gitlab.com
Tue Aug 21 12:51:35 BRT 2018


Álax Alves 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'")

@diguliu I think it is because we had to iterate through all fields when formating the data, we needed to group all fields, otherwise the same field would show in several rows, this would make formating the data very difficult.

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/noosfero/noosfero/merge_requests/1597#note_95914621
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/20180821/e7f6e726/attachment.html>


More information about the Noosfero-dev mailing list