float support
gdoteof - March 30, 2009 - 02:47
| Project: | User Points |
| Version: | 6.x-1.x-dev |
| Component: | Code: userpoints API |
| Category: | feature request |
| Priority: | normal |
| Assigned: | gdoteof |
| Status: | needs review |
Description
As we discussed, I needed float support. It seems to be working fine.
The patch basically changes every reference to points or max_points from an int to a float, and updates the .install file to alter the database so the point columns are floats instead of ints.
| Attachment | Size |
|---|---|
| addFloat.patch | 9.8 KB |

#1
The patch is welcomed but it has problems.
each .install update is marred with this typo change
- db_change_field($ret, 'userpoints_txn', 'tid', 'tid', array('type' => 'int', 'not null' => true, 'default' => 0, 'length' => 11));
- db_change_field($ret, 'userpoints', 'tid', 'tid', array('type' => 'int', 'not null' => true, 'default' => 0, 'length' => 11));
+ db_change_field($ret, 'userpoints_txn', 'tid', 'tid', array('type' => 'int', 'not null' => true, 'default' => 0, 'lenght' => 11));
+ db_change_field($ret, 'userpoints', 'tid', 'tid', array('type' => 'int', 'not null' => true, 'default' => 0, 'lenght' => 11));
note the 'lenght' misspelling for the last db_change_field. each update has this error.
Can you please fix this error and reroll the patch.
Thanks
#2
oops. i even brought up the typo in the first place :). with typo fixed
#3
Reviewed visually and removed some stray files and hunks.
Here is the reformatted version.
#4
visual once-over looks good to me, I'm excited for it.
#5
Huge +1 for this one -- makes purchasing with point via Ubercart possible without having to round the order total. Applied the patch and it worked fine, except for one problem that arises due to using floats:
Once you add or subtract float points i.e. (50.54), then you start getting lots of digits for values like "Approved points balance" on the /myuserpoints page. This is because when MySQL does SUM() on a FLOAT column it pulls numbers with lots of numbers after the decimal point because floating point numbers are only approximate. So, two options: use DECIMAL instead or round the values in the summary.
#6
#7
Attached is a patch that adds a setting specifying what precision to display and then formats the points when they are displayed with that level of precision.
#8
Adding a revised patch that fixes some bugs that showed up when users had more than 1000 points.
#9
I want to commit this, but due to the fact that most contrib will not work properly until they deal with floats, I think that we should branch t 6.x-2.x-dev (DRUPAL-6--2) then commit this.
That is unless some kind soul(s) volunteer their time to changing all userpoints_contrib that are in 6.x-1.x-dev to the new API and make it ready for commit when I am ready.
What does everybody think?