Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
- Decide on proposed resolution
- Write a patch
- Review
- 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.
Comment | File | Size | Author |
---|---|---|---|
#6 | 2944091-7.patch | 4.08 KB | jrockowitz |
|
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedMaybe 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.
Comment #3
idebr CreditAttribution: idebr at ezCompany commentedAfter 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.
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedWebforms are config entities (YAML) and submissions are content entities (Database). I am not sure if there are any tables that can be joined.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@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.
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI 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).
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch. Please download the latest dev release to review.