FM-17 / poglink

A bot that integrates the ARK Web API with Discord.
MIT License
12 stars 4 forks source link

Rates should only be posted once they are "stable" #49

Closed travipross closed 2 years ago

travipross commented 2 years ago

Currently, if rates are frequently changing back and forth between values for a period of time, this will result in a larger number of notifications than necessary.

The Rates cog should be updated such that it only updates on changes to a "stable" set of rates, so that momentary changes are ignored. Stable values are defined as those that remained constant between two subsequent polling intervals. The sensitivity to changes can be adjusted by tuning the polling interval appropriately.

In updating this behaviour, there should also no longer be any need to write previous values to disk. Thus, output_dir can be removed as a parameter.

See below for a pseudo code representation of the new proposed workflow for the main program loop:

stable_rates = None 

Loop 
    Check server for current rates (current_rates)
    Load previous server rates from disk (last_rates)
    Compare these to get diff (rates_diff)

    if rates_diff.items: # if there was a difference, reset the count and update previous rates 
        rates_unchanged_ct = 1 
        last_rates = current_rates 

    else: # if no difference from the last time, increment the count 
        rates_unchanged_ct += 1

    if rates_unchanged_ct >= 2: # rates have now been constant enough to consider them stable 
        if stable_rates:
            get diff between current rates and stable rates (stable_diff)
            if stable_diff.items:
                notify users of change 

        stable_rates = current_rates
github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 0.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: