Thanks for the formula!
Actually the PPs are stored in the matches table in the DB. However, they are listed only on the player/team profile page. I did it that way because in the admjn interface I select the match to edit and then assign a PP to one of the participants. This design may not be optimal, but honestly the whole ladder code isn't very good either
But never the less I can still get the date of when the last PP was given (for finished matches I would take the date of when the match report was accepted and the match was published, for unfinished (deleted) matches I'd take the challenge-date itself). Getting the total number of played matches or total number of penalty points is easy, too. So basically your idea is probably better than just letting pass a defined amount of time and deleting the PP from a match if the date is older than 6 months or whatever the time is. Your proposed default values (10 matches to play after the last PP-match and this within 3 months or more) are not good imo. maybe 3 matches and 4 months ? Any ideas ?
Just for the other ones I'll describe how it would work (it's a script executed daily for checking the database for inactive users):
The script does the following for every player/team that has one or more PPs:
- Create a list of all PPs of the user, and when they happened (I'll use an array for this, I do this because this information is not always in the same field and as such I cannot jsut do one SQL query and sort it right from the beginning)
- Find out when the latest (the "newest") PP occured, store information in <lastPP> variable
- Only continue with the script, if the player has had <MINMATCHES> matches (FINISHED matches) after the <lastPP> point of time
- If condition above is true, check if the time difference between <NOW> and time of <oldestPP> is >= <MINTIME>, if yes, delete the oldest penalty point.
The last point will not run in a loop, but only once, so it would delete max 1 PP per script execute. Sicne players don't get PPs daily (but the will check it daily) this will be enough.
So as defaults I could propse:
<MINTIME> =
4 (minimum number of months to pass after the oldest penalty point)
<MINMATCHEs> =
3 (minimum number of consecutive matches that need to be played and finished after the last PP).