#3068 closed task (blessed) (fixed)
User engagements
Reported by: | johnjamesjacoby | Owned by: | thebrandonallen |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | 0.7.2 |
Component: | API - Engagements | Keywords: | has-patch |
Cc: |
Description
We've kept a count of unique user voices since the early days of bbPress. What we haven't done is keep an actual running tally of the user IDs themselves, to see what topics they've engaged in.
With the User Relationships API now in trunk, we can do this relatively easily.
Things to do:
- Lift the base functionality from favorites & subscriptions
- Hook it all in to new topic & reply creation
- Only update voice counts when engagement changes
I'll attach a first-pass patch shortly.
Attachments (4)
Change History (37)
#3
@
8 years ago
- Component changed from Component - Topics to API - Engagements
- Keywords commit added; has-patch needs-refresh removed
First pass at the Engagements API imminent.
cc @thebrandonallen
#14
@
8 years ago
- Keywords has-patch added; commit removed
Finally had a chance to go over this.
3068.1.voice_count_bump_functions.diff introduces voice count bumping functions, and some "maybe" update functions. These are then used to move the call to bbp_update_topic_voice_count()
mostly out of bbp_update_reply_walker()
and onto bbp_new_reply
|bbp_{action}_reply
hooks.
Using the "maybe" update functions prevents all the database churn caused by deleting/re-adding all _bbp_engagement
post meta. There's no real raw performance boost here (about .05 seconds faster), but those with busy forums should see a lift. The maybe update functions only act on a single _bbp_engagement
post meta item, and they only do this when absolutely needed.
I'm fine if we don't do this, but either way I'd like to see the update voice count function on a hook. I've got some ideas to get rid of all of the
if ( in_array( current_filter(), array( 'bbp_deleted_reply', 'save_post' ), true ) ) { // Update counts. }
checks as well. Those will be on a separate ticket.
#15
@
8 years ago
Attached patch 3068.1.voice_count_repair_upgrade_queries.diff improves the voice count repair/upgrade queries.
Repair:
- Adds a
GROUP BY
clause to weed out duplicate engagement entries for each topic - Removes unnecessary
ORDER BY
statement from when I was testing - Rename
$voice_id_sql
to$engagements_sql
to better reflect what's actually contained
Upgrade:
- Adds a
GROUP BY
clause to weed out duplicate engagement entries for each topic - Use a single
wpdb::query()
rather thanwpdb::get_results()
, loop through each item, check its existence,add_post_meta()
, then bump the updated count.wpdb::query()
allows us to do all this in one take.
#17
@
8 years ago
Awesome! Thanks for these. r6340 is a nice improvement, but I just had a thought after I reviewed it.
If we upgrade engagements this way, we aren't busting the post caches of each topic that's receiving the new _bbp_engagement
meta keys. So, I think we'll still want to loop through them, or we need a way to invalidate the correct topic caches and their associated meta-data caches.
#19
@
8 years ago
Attached patch, 3068.1.hooked_voice_count_update.diff, moves bbp_update_voice_counts()
to hooks, as a safer alternative to 3068.1.voice_count_bump_functions.diff.
In 6311: