Problem/Motivation

Followup for #2943237: Implement tablesorting in webform overview for title, description, category, status, owner

Tablesort allows for sorting of entity properties. However, the 'Total results' column is not a property of the Webform entity so it cannot be included in the tablesort query.

Proposed resolution

Rewrite the WebformEntityListBuilder::getEntityIds() to check for a specific query key 'results_total' and do a manual join to the webform submission table to get the appropriate results

Remaining tasks

  1. Decide on proposed resolution
  2. Write a patch
  3. Review
  4. Commit

User interface changes

The 'Total results' column can be sorted in the Webform overview.

API changes

To be determined.

Data model changes

To be determined.

CommentFileSizeAuthor
#6 2944091-7.patch4.08 KBjrockowitz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

idebr created an issue. See original summary.

jrockowitz’s picture

Maybe we should add a \Drupal\webform\WebformSubmissionStorage::getTotals() method which executes an SQL query that gets the totals for all webforms or selected webform ids.

The SQL query would be...

SELECT webform_id, COUNT(sid) AS Total FROM `webform_submission` GROUP BY webform_id

If the table is sorted by 'totals', we would have to execute this query for all webforms, if the table is not sorted by 'totals', the query should be limited to displayed entity ids. Using a single SQL call to get all the totals would be a performance improvement.

idebr’s picture

Issue summary: View changes
Status: Postponed » Active

After doing some research it appears you can actually use tablesort with joined tables: https://www.drupal.org/forum/support/module-development-and-code-questio...

This makes the proposed resolution a lot easier. Updated the issue summary accordingly.

jrockowitz’s picture

Webforms are config entities (YAML) and submissions are content entities (Database). I am not sure if there are any tables that can be joined.

jrockowitz’s picture

@idebr Are you up for this task? There is no rush on this feature but if you are interested in working on this issue please re-assign this ticket to yourself.

jrockowitz’s picture

Assigned: Unassigned » jrockowitz
Status: Active » Needs review
FileSize
4.08 KB

I was staring at this ticket and decided to take a crack at it.

It was little trickier than I expected because we need to query webform submissions (content entity) and webform (config entity).

  • jrockowitz committed 0e7ac83 on 8.x-5.x
    Issue #2944091 by jrockowitz: Implement tablesorting in webform overview...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.