Closed (fixed)
Project:
User Points
Version:
5.x-3.x-dev
Component:
Code: userpoints
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Feb 2008 at 14:19 UTC
Updated:
13 Aug 2011 at 04:30 UTC
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
Comment #1
jredding commentedThis 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.
Comment #2
kmillecam commentedThe 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
Comment #3
jredding commentedWhere are int and %f (indicating a use of printf) used in the module? that seems odd.
Comment #4
kmillecam commentedMy 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.
Comment #5
jredding commentedoh, so you must have also changed the DB?
Comment #6
kmillecam commentedYep.
It actually works really well.
Thanks for the listening ear.
Kevin
Comment #7
IWasBornToWin commentedI can't find the %d anywhere. Can you please tell me where to find it so I can change it to %d
Thanks