Hi guys,

I'm just wondering why userpoints have to be granted in whole numbers (int)? I know you must have chosen that design philosophy on purpose and I'm guessing it's tied to performance (but I'm not sure).

Please share your insight.

Thanks,
Kevin

Comments

jredding’s picture

Status: Active » Closed (fixed)

This is talked about somewhere in the issue's queue but I understand that the issue queue can be hard to search sometimes (subliminal message: at DrupalCon there is a Project.module code-athon... you could help add some nice features!)

integers are less intensive on the DB than decimals in terms of storage and performance. Also an integer is turned into a monetary decimal by simply dividing by 10 and manually adding the "."; which is a really common way of doing it. 100/10 = 1.00 ;)

Note that there is actually nothing in code that forces a decimal, at least nothing that I can think of. So if you really wanted a decimal you could simply change the DB and you'd be set.

In the meantime Integer it is for performance and storage reasons.

kmillecam’s picture

The reason I asked is I have a client who sticks to integers pretty well but they give .5 points for a vote and .1 points for an affiliate click.

Each time a new version of User Points is released, I find myself searching (and usually removing) references to int and %f

jredding’s picture

Where are int and %f (indicating a use of printf) used in the module? that seems odd.

kmillecam’s picture

My mistake,

I was ireferring to the %-modifiers used in queries. I've had to change a number of the %d modifiers (that carry integers) to the %f modifier (that carry float values) in order for the userpoints module to process decimal point values. (I had that backwards in my earlier post).

WRT (int), just did a quick search of the 5.x-3.x code and found 12 occurrences.

jredding’s picture

oh, so you must have also changed the DB?

kmillecam’s picture

Yep.

It actually works really well.

Thanks for the listening ear.

Kevin

IWasBornToWin’s picture

Component: Code: userpoints API » Code: userpoints

I can't find the %d anywhere. Can you please tell me where to find it so I can change it to %d

Thanks