Closed (fixed)
Project:
Userpoints Evaporate
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
26 Nov 2011 at 18:02 UTC
Updated:
10 Jan 2012 at 22:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
cafuego commentedI'm not really using D7 yet, so I haven't looked at porting it. If the schema hasn't changed, I imagine it's mostly a matter of rewriting the queries to use the new database API layer.
Comment #2
migala commentedIt would be interesting to port this module to D7.
Thanks a lot
Comment #3
dRaz commentedHi Migala.
Do you mean you are interested in porting it or interested in a port (by someone else)?
Comment #4
migala commentedI can port it, but since my last comment I discover that the functionality of this module are implemented in userpoints so I think porting this module is not necessary.
Maybe I'm wrong.
Comment #5
dRaz commentedI do not see the functionality available within userpoints but am currently working on a workaround using rules.
Perhaps you can point out the error here as it all looks fine to me but is not working....
The rule basically:
When a user logs in, the system checks to see whether it has been (for testing purposes) 3 minutes or longer since they last logged in.
If it has then they lose 30 points.
My rule setup:
Event: user logged in
Condition: php: return intval((time() – $account->access)/60) > 3;
(this should allow the user 3 minutes interval where if they log in they will not be penalised)
Action: grant userpoints -30
It all seems fine to me but isn't working for some reason.
Can you point out the error please - it must be within the condition?
Thanks,
Shaun
Comment #6
cafuego commentedA 7.x-1.x-dev release of the module should be available shortly. Please test :-)
Comment #7
cafuego commentedComment #8
dRaz commentedTesting now.....
EDIT:
Install - fine
Admin links - not present in the menu but can be found at admin/config/people/userpoints/evaporate
Configuaration saves.
Now have to wait an hour to see if it works :) .....
EDIT:
Points do not evaporate.
After an hour I ran cron, logged in my user (after an hour and 10 minutes) and the points were the same as before.
Still needs work here.
In the meantime, if you could help with the above code that I posted, we have a temp fix.
Thanks for your efforts,
Shaun
Comment #9
cafuego commentedCan you check what the watchlog log says for userpoints_evaporate? I checked that the queries ran locally, and my installation does log that it has evaporated some points, but I didn't actually check that the points had gone, now that you mention it :-P
Will do so shortly :-)
I've not used Rules on D7, mainly because it's always given me errors and WSODs, so I can't help with that one...
Comment #10
cafuego commentedI see the problem, the named placeholder in the query that updates point totals is parsed as a string, so the query fails silently.
Comment #11
cafuego commentedThe DB API is not cooperative and refuses to interpret the number of points to be deducted as an integer, so I've had to include the value in-line in the query, without using a placeholder.
That updates the totals for me when cron runs. A new 7.x-1.x-dev release will be built when d.o next does its cron builds.
If you need to test sooner, you can apply the attached patch to your 7.x userpoints_evaporate module.
Comment #12
dRaz commentedGood work Caf, I have made the changes, just waiting now to see if working.
Have you tested the "inactive only" function too??
Comment #13
dRaz commentededit: see below
Comment #14
dRaz commentedWell, after leaving the "test" for 11 hours...
This morning I had the following results (bare in mind cron runs every 3 hours):
-10 Content Tue, 13/12/2011 - 22:32 Lost due to inactivity Approved view
-10 Content Tue, 13/12/2011 - 22:32 Lost due to inactivity Approved view
-10 Comments Tue, 13/12/2011 - 22:32 Lost due to inactivity Approved view
-10 Comments Tue, 13/12/2011 - 22:32 Lost due to inactivity Approved view
So, something is not working as it should.
I have the following settings:
Every hour, evaporate 10 points for users who have been inactive for over 1 hour.
What is the code to check for inactivity as I must be close with my rule condition?
We can have a workaround for this whilst the module is in dev if you can point out the error in my above code:
My rule setup:
Event: user logged in
Condition: php: return intval((time() – $account->access)/60) > 3;
(this should allow the user 3 minutes interval where if they log in they will not be penalised)
Action: grant userpoints -30
The same inactivity php logic is tryign to be used here?
Thanks,
Shaun
Comment #15
cafuego commentedOkay, I've set up a site in aegir to be able to test this thing properly. There were two problems I've found and (hopefully) fixed in regard to this issue:
I've fixed the transaction insert query to only affect the specific points category on each run and added a query to update the total points per user in the userpoints_total table. Should be in the next available 7.x-1.x-dev release.
Also, I've moved the configuration to a tab on the userpoints module configuration.
Comment #16
dRaz commentedGood work Caf, all sounds very promising.
Have you tested the "inactive" users feature also?
On a personal note, that is what I will be using this module for - removing points from inactive users.
Comment #17
cafuego commentedYup, it's been running on my system overnight and it *looks* to be working as intended. I have a category that expires 5 points for inactive users each hour and a category that expires 1 point for all users each hours.
Both have worked correctly for the past 13 hours. All users have lost an equal amount of the points that always evaporate, the admin user has lost less of the points that only expire for inactive users because I've been using it to check results.
That is the codebase I checked in over 12 hours ago, so the current 7.x-1.x-dev should include those fixes.
Comment #18
dRaz commentedI'll give it a test Caf :)
Comment #19
cafuego commentedI note that userpoints_no_negative was not ported to D7, so I'll add functionality to evaporate to set 'No negative' as option for each category... my users now have -6 points :-) ( #1372452: 'No Negative' function in D7 port)
Comment #20
dRaz commentedThat sounds like a good idea.
An alternative may be to add a limit, so:
if user has 30> points then evaporate else don't evaporate
Shaun
Comment #21
dRaz commentedOk the module seems to be working fine but I have a question about it's logic:
Settings:
lose 10 points every 1 day
inactive users only
inactive for 3 days.
How does the above work?:
a) if they are/have been inactive for 3 days they will lose 30 points when they log in (10 for every day they have been inactive)?
b) they will begin losing 10 points per day after 3 days?
I beleive it should work like b) but I have a feeling it is working like a)
Can you claify? Thanks.
Shaun
Comment #22
cafuego commentedThe module works like "b" indeed.
It doesn't work on an event basis at all, the design is instead to minimise database load and bulk evaporate points for *all* affected users simultaneously. So the module rather than patching in to Rules, uses hook-cron and runs its code on every cron run.
If a user hasn't logged in for 3 days, the module starts evaporating 10 points per day for that user.
That means it runs two SQL queries for each of the configured categories in order to set points for *all* users. After that, it now runs one additional query to update the grand totals. It's designed that way to be able to quite quickly evaporate points on a site with tens of thousands of users without looping through a Rule (calling a userpoints API function) tens of thousands of times each cron run.
Comment #23
dRaz commentedOk thank you.
The no-negative feature is definately required then in that case as new users may not log in for 3 days after creating their account and will be deducted points upon first login....
How are you getting on with that? :)
Comment #24
cafuego commentedThat seems to be working, as the test users have 0 points in one category and -72 in the other :-)
I'll mark this issue as RTBC and add a patch to the nonegative issue (as well as commit to -dev).
Comment #25
migala commentedin admin/config/people/userpoints/settings you will see this tab:
"Expiration",
there are the userpoints expiration feature.
Still thinking porting this module is not necesary.
HIH
Comment #26
cafuego commentedExpiring a points transaction after a set period is not the same as expiring a fixed number of points repeatedly after a given time interval. Userpoints does the former, this module does the latter.
Comment #27
migala commentedSorry, you're right.
I had not understood.
Thanks for your info.
Comment #28
cafuego commentedPushed 7.x-1.0-beta1, which includes these fixes as well as the no-negative functionality.
Marking this issue as 'Fixed'.