Follow-up to #1986606: Convert the comments administration screen to a view
Problem/Motivation
There is an utter lack of filters on the comment admin screen.
Proposed resolution
Add some exposed filters because it is a view now.
Remaining tasks
Agree on the filters.Add filters.Update path.Not needed see #13Update path tests.Not needed see #13- Review.
- Commit.
- Rejoice.
User interface changes
Comment admin screens have filters now.

API changes
None.
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #39 | add_filters_to_the-2898344-39.patch | 23.83 KB | jibran |
Comments
Comment #2
jibranAdded a comment subject filters just like node title on node admin page.


Added author and username combine filter to by comment author name.
Added comment type filter just like node type filter.
Added language filter just like on node admin page.
Query:
Comment #3
jibranNow with the update path.
Comment #4
andypostthere's no reason for ETM variable cos it used only once
Comment #5
jibranNow with tests.
Comment #7
dawehnerCongratulations on getting the conversion in! I'm wondering whether we should do some simple testing of the exposed filters?
Do we consider it as fine to override a view someone might have adapted? I guess its fine, given we have never promised it?
Comment #8
jibranSure
I'm open to suggestions.
Comment #9
lendudeDo we have any way to handle/detect if people made modifications to the View before we load the new version? Cause this way we just discard any updates that people have done.
I think a lot more people will benefit from adding the filters but this could theoretically lead to loss of data. And we can't really mark UI exposed config as @internal.
Edit: cross post with @dawehner, guess we thought the same thing :)
Comment #10
dawehnerIf we would stay in 8.4.x, we could just override it, we wouldn't even need to provide an update path, given that we don't need to support one.
Let's assume this won't make it to 8.4.x, but rather just in 8.5. IN that case we could use the config hash stored in
_coreto determine whether things got changed.Comment #11
jibranJust for the reference core default_config_hash is:
#2560049: Incorrect capitalisation of translatable strings, #2600576: MIME, not Mime / mime and #2712647: Update Symfony components to ~3.2 all made changes to the file admin default view without updating the existing view in storage. We can totally drop upgrade path for it if it won't make it to 8.4.x.
Comment #12
jibranAdded a test for expose filters. This is ready for review.
Comment #13
dawehnerLet's a good idea as well. Given that we don't want an update path in 8.4.x, but then also want to drop one afterwards, let's just no worry about it anymore 🎆
Comment #14
dawehnerNice work with the test!
Comment #15
jibranRemoved the upgrade path.
Comment #16
andypostLooks good to me!
Comment #17
dawehnerNice test coverage!
Comment #18
xjmThis looks great! Nice to see the test coverage as well.
I was going to say that the language field should only be displayed on a multilingual site "like for nodes"... but then discovered that
admin/contenthas a language filter even on a monolingual site in HEAD, with all the confusing/overwhelming options that nodes do. So I guess that's not in scope here, but I'd want to see a followup or two to (a) only display the language filter when content might exist in more than one language and (b) not show confusing, irrelevant options. Issues for these might already exist.admin/content.)I don't think we should have this in the patch; the view has only been added in 8.4.x which has not shipped a release yet. Unless I've missed something?
admin/contenthas "Action" as the label, which is more informative.Comment #19
xjmOkay, out-of-scope point 1 is a whole can of worms. Relating some of the related issues.
I wonder if we could improve the situation by only displaying these exposed filters if more than one kind of the thing exists on the site? That would also fix point 3. That's magic and an extra query, so probably should be a followup, and we go with just doing the same meh thing that nodes do at the moment. So let's make that a followup issue (for both this view and admin/content maybe), and just go with my suggestion of removing the comment type filter for now.
Comment #20
jibranThanks for the review.
Comment #21
jibranAgreed, let's do it in the follow-up issue.
I still think having the filter out weights not having it. This view is not shipped with the standard profile it is shipped with the comment module so I don't strongly buy into 80% use-case argument.
Comment #22
andypostIMO comment type is useless
Right now it used just to point to which entity type the comment field is bound to.
But 80% case is nodes
If someone will decide to add comments to products or taxonomy able to edit default view and customize...
To have a documentation page with few sentences about that makes sense otoh better to add it to change record
Comment #23
xjmI still think we should remove the comment type filter. (A content type filter from the node relationship would me more useful than a comment type filter, even. Edit: Not saying we should add that since it would make the view node-specific; just offering it as an example.) If someone wants to have multiple comment types on their site, it's very easy for them to add a comment type filter to the view (that's the point of it being a view, after all). :)
I don't think it's tricky to add later either if we decide it is worthwhile?
I guess a usability maintainer could weigh in on whether we should include that filter.
Comment #24
Bojhan commentedI agree with @xjm, it seems like we would be optimizing for a use case thats just not the 80%, and people who do that likely know how to adjust a view.
If possible we can do some special logic to hide it if it's only one?
Comment #25
jibran> If possible we can do some special logic to hide it if it's only one?
I have some ideas around that but that's way out of the scope for this issue.
Comment #26
Bojhan commentedThen we should not show it, lets aim for the 80% usecase.
Comment #27
jibranAdded #2900516: Allow hiding expose filter with only one choice for #24. Addressed the usablity review in #26.
Comment #28
andypostIMO good to go
Comment #29
lendudeAwesome test coverage! Just some really tiny nits:
Maybe use 'author_name' here? Much clearer in the URL when searching (would also need an update in the test then afterwards)
comment => comments
one space too much between using and username.
Comment #30
jibranThanks, @Lendude for the awesome review. Here is an updated patch fixes everything form #29.
Comment #31
lendudeNice. Updated the screenshot to the most recent version of the patch.
Comment #32
xjmSo this does add a relationship to the existing view, which we'd typically want to profile per https://www.drupal.org/core/gates#performance. However, I looked over #1986606: Convert the comments administration screen to a view and I don't see any documentation of profiling there either. :P I'll check with catch.
Does this mean that we didn't give semantic display names to the tabs of the comment view? We should fix that if so. (Out of scope here but we'd want to backport that if possible before beta.)
Nit: This is not really a sentence.
Nit: exposed filters.
This isn't actually asserting that the anonymous comment is visible; it's asserting that one comment of some sort is visible. We should add assertText()s and assertNoText()s for the comment we expect to have displayed.
Should we test with another language also?
Comment #33
xjmComment #34
xjmFor #32.2.
Comment #35
xjmComment #36
mradcliffeI will work on analyzing the query changes using EXPLAIN to see performance impact. First will need to generate many users and comments since the join is on the user table.
Comment #37
annajl commentedFixed #32.3 and #32.4
Tim Plunkett said I don't need an interdiff. Leaving it at needs work because the other issues still need to be fixed.
Comment #38
jibranThanks, for the review.
Re #32:
views.view.contentpage display is also called page_1 so I followed that. I agree we should discuss it in a follow-up and rename all admin views displays.Comment #39
jibranFixes minor doc issues.
Comment #40
annajl commented#2901778: Provide correct display name and title for comment admin view displays
I've created a follow-up issue for #32.2.
Comment #41
mradcliffeI was having some development environment issues and wasn't able to get to finish performance testing today.
Comment #42
jibranSo?
Comment #43
mradcliffeSorry. I didn't mean to change the status.
Comment #44
jibranAll good @mradcliffe. Now we have to conversations going one in #1986606-373: Convert the comments administration screen to a view and one here.
Edit: And I'm sorry about my abrupt reply I didn't intend it like that.
Comment #45
mradcliffeThe 4 possible queries running here are
In PostgreSQL 9.6 the query planner did well for everything except #1 and #2 and used the index on the users_field_data table. However for some reason it did not choose the index scan when only the author name filter was done. Not using the index increased the "cost" of the query significantly. If I only filtered on the comment author name, then the index WAS used. It's possible the query planner made the correct decision because as the number of rows increase it gets more expensive to run the index. This probably happened on my VM with 4gb memory using 1 vcpu with 10000 users and 10000 nodes with max of 50 comments where the name I searched for returned about 1-50 rows (after limit). This was also done after auto vacuum as I got the data in there yesterday and have done subsequent restarts of the VM since then.
MySQL should also have similar behavior with choosing indexes, and it looks like EXPLAIN in #1986606: Convert the comments administration screen to a view.
I did not see any significant issues with the query, and I think views is doing a good job here.
As @andypost noted in #1986606: Convert the comments administration screen to a view there may be render performance issues, but that's probably more to do with views in general rather than adding in filters? If anything filters would improve render performance by reducing the number of comment entities to load individually.
Comment #46
xjmThanks @mradcliffe, nice detailed summary.
Comment #47
larowlanThanks @mradcliffe, appreciate the profiling and analysis
Comment #48
catchlarowlan did a blackfire comparison and it looks like there's a small performance improvement in rendering (which has he pointed out, makes sense given Views has had a lot of render caching attention compared to comment admin controller by now). Thanks for the testing!
Comment #49
xjmThe above addresses all my feedback. RTBCing (which means I can't commit it), but if someone else can review/confirm @jibran's changes then I could commit it also.
Comment #50
larowlanThe last round of changes (last two interdiffs) look good to me.
Comment #53
xjmAlright, committed and pushed to 8.5.x and backported to 8.4.x since this view is new in 8.4.x anyway. Thanks everyone!
Comment #54
jibranThank you all. I don't think we are missing any follow-ups from #18 or #32.