I noticed that the point balance listed on my user's profile pages only reflects "uncategorized" points.

Can the query that returns that number be updated with a SUM() so it reports points in all categories?

Thanks,
Kevin

Comments

kbahey’s picture

Actually, we should change that to be:

If we pass in a tid to those queries, it should return only the points for that category.

If no tid is passed, then a SUM() is performed across all the tids.

Need jredding's opinion on that too.

kmillecam’s picture

Good thinking Khalid.

That's a more useful solution.

jredding’s picture

the way the functions work is that if you pass a tid you'll get that category otherwise you will receive the default category.

The call is
userpoints_get_currentpoints(uid, tid)

So that you can get a specific user and/or a specific tid.

Now its not a problem to simply all a string in the tid statement 'all' which would do a sum. This shouldn't be the default behavior.

The categories were designed to allow modules to separate out their points not to simply put a category on them thus a sum() in that case makes no sense. As an example I'm using the categories to separate points gained through point_basic events (node adds, comments, etc.) from my quasi "financially" gained points which are manually granted.

I will NEVER want a sum of these two points as they are completely different thus having a default of sum() would make my life much harder.

Additionally ever contrib module would need to be modified to specifically ask for non SUMed points as they all currently only work with the default category.

ssoooo... to make life easier for everyone if we really want to implement ability to return SUMed points you should be able to make tid = 'all'.

Finally: I did think of this for the profile page. If you take a look at the variables passed in, once of them is "Summed points". Its just an addition done POST DB of all the categories returned. Check the theme functions.

Summary
1) default behavior of SUM() == very bad
2) tid == 'all' returns sum() OK sounds fine to me
3) On the profile page this can already be done without changes. Check the theme functions its all there.

kmillecam’s picture

I didn't realize you had planned far enough ahead to pass the $tid with these functions.
Nice thinking!

Solution 2 is a good one. +1 from me.

Agree that default SUM() would be bad.

Solution 3 assumes that users only want to see a total of their uncategorized points on their profile page (or that they have a developer on hand to leverage the theme functions).

jredding’s picture

Category: bug » feature

I just want to change this to a feature request as there is no bug and we're talking about expanding the flexibility of the call.

Are we in all in favor of add tid == 'all' returns a SUM() of all categories?
The only thing i don't like about it is that $tid is an INT and now we're passing a string so we're mixing variables types. I understand PHP isn't sensitive about those things but I try to be constant in that. I'm willing to let it slide though, I'm not that uptight... ;)

kmillecam’s picture

I like the tid == 'all' solution.

It will allow me to use your functions to return aggregated info.

Thanks,
Kevin

jredding’s picture

both userpoints_get_current_points and userpoints_get_max_points have been updated so that if $tid == 'all' a SUM of the points will be returned (i.e all categories)

jredding’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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