Store the points being granted with addPoints() to the revision

Created on 28 July 2023, over 1 year ago
Updated 21 August 2023, over 1 year ago

Problem/Motivation

I'm trying to show a block listing the users with the most points earned in the past 30 days.

In 8.x I was able to do this by querying the transactions created in that time frame and aggregating the sum

in 2.0.0 each transaction is now a revision of the users userpoints entity. The total quantity is increased but we dont store the number that it was increased by in the revision.

This is preventing me from querying the total points within a specific timeframe.

Proposed resolution

Store the points being granted in a new field of the revision.

✨ Feature request
Status

Active

Version

2.0

Component

Code: userpoints

Created by

πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @loze
  • I had the exact same problem. I agree that the module itself should be able to do this, but since that's not the case I just built a custom module with a transactions table that implements hook_ENTITY_TYPE_update() for the userpoints entity type and updates the custom table accordingly by taking the difference of the original and the new entity. Maybe that approach would also work for you.

Production build 0.71.5 2024