I know this has been asked several times in one form or another, but after a LOT of searching, I have not been able to find an answer. There were a few answers that pointed to the php code itself, or to the points page in Admin. But, none explained how they are calculated and processed by the script. In other scripts that track points (or other user log activities), they are generally handled with two DB tables and a Cron job scheduler.
1. Daily running table (TABLE 1) that tracts individual activities similar to the following :
USERID |
REASON |
POINTS |
user1 |
aupvote |
1 |
user2 |
cpost |
5 |
user1 |
aselected |
2 |
user1 |
cdownvote |
-1 |
user3 |
bonus |
50 |
This table could have thousands of records.
2. Second Table is the main points summary table (call it qa_userpoints)
At the end of each day a Cron is run on table 1 that tabulates the data and inserts that into table 2. Table one is then emptied and a new day starts. All stats shown to users is taken from table 2. I am aware the following under this scenario:
A. Points that users see would be as of the prior day.
B. When the point values are updated, the previous amounts earned would not change. They only change moving forward.
I am not sure how the current system works. I see point values in several tables, a Recalculate button on the points page, and a plugin called Point Recalculator. This is not to mention 3rd party plugins all using their own tables.
What I am looking to understand is the current flow on how points are calculated. I am not even sure how it is possible without using Cron jobs unless the script is looking at (and calculating) all the various tables and data in real-time.
Another question:
1. User1's current point total is 196 (in qa_userpoints)
2. User1 asks a question that gives him 5 points
It looks like this increases the qposts number by 1. So how does this translate to an additional 5 points in the user's total points when viewing it on the site?
or
1. User1's current point total is 196 (in qa_userpoints)
2. User1 pins a post with a 3rd party plugin that costs him 50 points
How does this translate to a reduction of 50 points to the user's total points? (I understand that different plugins handle this differently, but they still need to add or subtract from the points somehow).
I know from reading other questions regarding points both here on Q2A and on Github, that this is a touchy subject for the contributors. I am just trying to understand the thought process here since I am seeing some weirdness with the point totals.
Thanks in advance!