New form of automatic points adjustment

  • Hey,


    I was looking at adding functionality that resembles how most point collection programmes (such as airline mileage programmes) work:

    You get awarded points and they decay at a certain date in the future if not spent until then.

    By skimming over the code base and the wiki, I found that APAs might be the closest thing to that idea.


    I'm currently assessing what would need to be done for implementing such functionality as an APA.

    It seems that the magic is happening in the `get_value` function of the APAs.

    Thus, my main question here is what parameters is this function called with and when?


    As far as I can see, it seems to be called per member id, but I am unsure about the event id and various other parameters supplied in the data field.


    Thank you so much for your support. :)

  • It depends. The function get_value is called when you execute the APA manually (e.g. apa_onetime_current). Other APAs like apa_decay_current or apa_decay_ria are called when retrieving the current points of the character (apa_decay_current) or from the Raids, Items and Adjustments (apa_decay_ria).


    You will find a call here: https://github.com/EQdkpPlus/c…h_r_points.class.php#L363

    In the following lines, you will also find the data provided to get_value.

    Viele Grüße,
    GodMod


    Bitte sendet mir keine unaufgeforderten Support-PNs. | Please don't send me unwanted support-PMs.
    Du willst dich bei mir bedanken: | You want to thank me:

    amazon_wishlist.jpg paypal_logo.jpg

  • Okay, that helped me quite a lot. After digging a bit deeper, are the following observations all correct?

    • currentcap_current & cap_current store actual adjustments
    • decay_current keeps track of the decay in the member's apa_points only
    • decay_ria keeps track of the decay on a per item/raid/adjustment basis in its respective apa_value field

    Then, the get_last_run for the decay APAs is still a bit cryptic to me.

    In particular, I am not sure about the difference between $exectime and ($decay_start%86400).

    Is it something about timezones? Both seem to be the number of seconds from midnight in one form or another.


    Finally, I seem to be missing something about the zero time and I'm wondering about the following check: (($refdate - $intZeroMonths*2592000) > $last_run).

    Isn't $last_run calculated from the same timestamp as $refdate (which is also equal to $data['date'])?

    If so, as $last_run is continuously increasing with $refdate, how can it ever evaluate to true?

    Okay, $refdate is not necessarily equal to $data['date'] when the get_value is called recursively.

    However, decay current uses $refdate for the check, while decay ria uses $data['date'].

    As I said, I am probably missing something here and hope you can spot it easily. :)


    Thanks so much!

  • `currentcap_current` & `cap_current` store actual adjustments

    Yes, they create Adjustments to create the exact current point standing

    decay_current` keeps track of the decay in the member's `apa_points` only

    In apa_points the decay points will be saved as cache, so that a recalculation of the points and several calculation are not required.


    `decay_ria` keeps track of the decay on a per item/raid/adjustment basis in its respective `apa_value` field

    Same as above - apa_value is for the cache. The frontend shows the apa_value if decay is enabled.


    In particular, I am not sure about the difference between $exectime and ($decay_start%86400).

    It can be that there is no difference anymore. The whole APA thing has been written by a former developer which is not part of the Team for a long time now. Therefore, I just maintain the code and fix the problems with APA.


    However, decay current uses $refdate for the check, while decay ria uses $data['date'].

    Sometimes, refdate is not required by the APA module. All these APA modules have different purposes, therefore they sometimes use other data than other modules.

    Viele Grüße,
    GodMod


    Bitte sendet mir keine unaufgeforderten Support-PNs. | Please don't send me unwanted support-PMs.
    Du willst dich bei mir bedanken: | You want to thank me:

    amazon_wishlist.jpg paypal_logo.jpg

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!