Problem/Motivation

The names of some of these are totally misleading. It rather seems that as these were added over time, we just reached for combinations of the words 'flag', 'count', and 'entity' that weren't already used for existing functions...

Once #2476499: Give the documentation of the flag count API some love. has done the job of clearly explaining what each of these does, we should think about how to name them more clearly.

Proposed resolution

Discuss better names and change them.

API changes

The flag.count service's method names will change.

Remaining tasks

- write a patch
- update the CR at https://www.drupal.org/node/2476349 with the new method names

CommentFileSizeAuthor
#10 rethink_the_names_of-2481107-10.patch5.34 KBsocketwench
#9 rethink_the_names_of-2481107-9.patch5.32 KBAnonymous (not verified)

Comments

joachim’s picture

Issue summary: View changes
joachim’s picture

Copied from a duplicate issue:

getCounts() plural is appropriate when returning an array of individual counts.

but count/total singular should be used for

getEntityCount(),
getTotal()
getUserCount()

This will clash with the efforts to rename getTotals() but as long a we choose the singular version of that name ..

joachim’s picture

To summarize, we have 4 methods currently in the count API, which can be briefly described thus:

- get a summary of all the flag counts on a single entity
- get the count of all of a flag's flaggings
- get the count of all of a flag's flagged entities
- get the count of all of a flag's flagged entities for a particular user

Let the bikeshedding begin!

Off the top of my head, I propose:

- get a summary of all the flag counts on a single entity: getEntityCounts
- get the count of all of a flag's flaggings: getFlaggingCount
- get the count of all of a flag's flagged entities: getEntityCount (urgh! one letter away from getEntityCounts! We need something better)
- get the count of all of a flag's flagged entities for a particular user: getUserFlaggingCount

joachim’s picture

Bit more specific, but more wordy:

- get a summary of all the flag counts on a single entity: getEntityFlagCounts
- get the count of all of a flag's flaggings: getFlagFlaggingCount
- get the count of all of a flag's flagged entities: getFlagEntityCount
- get the count of all of a flag's flagged entities for a particular user: getUserFlaggingCount... but then strictly speaking, this one should be getUserFlagFlaggingCount, no?

joachim’s picture

Status: Postponed » Active
joachim’s picture

Status: Active » Needs review

I'm going to set this to needs review, since the proposed name changes need review before a patch is made.

socketwench’s picture

Status: Needs review » Needs work

All the names in #4 are good except getUserFlaggingCount(). It would make sense if the FlagInterface parameter was optional. If we plan on doing that, I'd be fine with getUserFlaggingCount().

Anonymous’s picture

Assigned: Unassigned »
Anonymous’s picture

Assigned: » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.32 KB

Here is my patch. I used getUserFlagFlaggingCount name for getUserCounts method because we didn't change it implementation.
Please review.

socketwench’s picture

StatusFileSize
new5.34 KB

Reroll.

  • joachim committed 7f0205c on 8.x-4.x authored by bobrov1989
    Issue #2481107 by bobrov1989: Changed names of the flag count API...
joachim’s picture

Status: Needs review » Fixed

> I used getUserFlagFlaggingCount name for getUserCounts method because we didn't change it implementation.

Yup, that makes sense.

Thanks for the patch & the reroll.

Committed, and CR updated.

Status: Fixed » Closed (fixed)

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