maybe-finance / maybe

The OS for your personal finances
https://maybe.co
GNU Affero General Public License v3.0
28.71k stars 2.19k forks source link

Bug: Line chart is not updating end date #940

Open scubamaggo opened 4 days ago

scubamaggo commented 4 days ago

Describe the bug It appears that the line chart is not updating the end date when the application is running for longer periods. It is stuck on the date when the application was started.

To Reproduce Steps to reproduce the behavior:

  1. Go to an Account with a transaction history. The last date will be the current date.
  2. Wait until the next day.
  3. The end date is stuck on the date seen in step 1 and will not update unless the app is restarted(?).

Expected behavior The end date should be refreshed when the server date changes.

Additional context I suspect this is due to the way the Period class is initialized. The class contains this code:

    BUILTIN = [
        new(name: "all", date_range: nil..Date.current),
        new(name: "last_7_days", date_range: 7.days.ago.to_date..Date.current),
        new(name: "last_30_days", date_range: 30.days.ago.to_date..Date.current),
        new(name: "last_365_days", date_range: 365.days.ago.to_date..Date.current)
    ]

    INDEX = BUILTIN.index_by(&:name)

This is called once upon class initialization, and I suspect this class is never(?) instantiated again via the provided chart methods.