CorruptedArk / did-i-take-my-meds

A Kotlin Android app to manage medications
GNU General Public License v3.0
175 stars 15 forks source link

Remove meds' logs entries to avoid lag and freeze of the app #79

Open serenity042 opened 1 year ago

serenity042 commented 1 year ago

To begin with, thank you for this wonderful app. As far as I know this is the only app in french that shows how many time have passed since last med intake.

Is your feature request related to a problem? Please describe. When taking the same med many times a day for many months, app begin to lag massively in transitions for opening a med page. The app can freeze for minutes. I suppose that this is related to the number of meds' logs entries.

Describe the solution you'd like Med log entries per med could be purged with a button. It could be just keeping logs entries since 60 days, or since any date the user could state, depending of what seems relevant to you.

Describe alternatives you've considered Maybe logs entries could be paginated so it does not load entirely when clicking a med.

In my situation, currently I could :

Additional context My mom use your app a lot for chronic pain related meds. But I have the app on my phone to test things if needed. EDIT : Hardware is Samsung Galaxy tab S3 LTE 9.7.

Again, thank you very much for your precious work.

(Sorry in case of disastrous English, it is not my mother tongue)

Krzmbrzl commented 1 year ago

I second this suggestion. The lag will increase steadily, the longer one is using this app.

jmichael2497 commented 1 year ago

it would be nice to have a cleanup option to clear entries older x days... but until then, here is a workaround suggestion:

daily buildup doesn't seems too bad, so for those maybe use annual labels setup ahead of time like 2024 x.

for something taken multiple times per day, maybe quarterly would be better like 2024q1 x.

set the start date for that next time frame for example 2024-01-01, then on that day edit and copy over the remaining doses info, mark the old entry inactive, mark the dose taken on new entry.

serenity042 commented 1 year ago

Thank you for your workaround suggestion, @jmichael2497 :)

Sadly it will not work in my case since the most used medication is taken as needed

I remain available if testing is needed!

jmichael2497 commented 10 months ago

the workarounds will still work in your case of taken as needed.

it seems like an obvious split: it is either never more than 1 per day, so treat it like daily and make the annual list.

otherwise make it quarterly (any more than that might be inconvenient to setup for remote elder tech support, which i am all too familiar with).

serenity042 commented 10 months ago

Hello @jmichael2497 :) Your input is really appreciated.

For this workaround to work on this Samsung Galaxy tab S3 LTE 9.7 — which is by no means low hardware — I would indeed have to make it monthly. Between the end of October and the end of December, massive lags were back for medications taken more than once a day. And some daily medications were lagging too.

However, I found another workaround, which I'm going to share since it's really efficient in my case. Be aware that this could delete logs. If history of log entries are important to you/your user this is not really functional, especially if you/your user is not tech-savvy. As my mom is good at organizing files when she is not in pain, this is not an obstacle in my case. There is an import/export option in the ⋮kebab menu.

  1. To not lose data, I exported the current lagging database in a dump. I named it MedicationsDump-[DATE].zip. So if needed it can be read.
  2. Next, I setted up again the list of medications my mom needs. Then, without adding a log entry, I exported it to a database I named MedicationsTemplate-[DATE].zip. I date templates because they can evolve if the prescriptions are modified.
  3. When meds' entries starts to lag, export the database in a dump as in step 1. Then import your template previously saved in step 2 – the latest MedicationsTemplate-[DATE].zip. Enjoy the smooth interface and praise the import export option :)

I remain available for patches testing

blhiggins commented 9 hours ago

I just encountered this sluggishness due to excessive accumulation of old doses. I don't have a pre-made pristine template of medications I could reset to using @serenity042's approach, so rather than recreate all the medications (I have several because I use DITMM for general reminders as well), I've found that it's possible to edit the backed-up database and remove the old doses. Doing this requires some SQLite DB tools, though: I used SQLiteBrowser on the medications file inside the ZIP file generated by the "Back up database" option. On the "medication" table of the database there is a "dose" field which contains a JSON-formatted list of old doses: you can simply replace that field with "[]" to delete all past doses, or select and remove individual items of the list by hand if preferred. (The times appear to be seconds from Unix epoch, and the list appears to be sorted newest to oldest.) Once the adjustments are made, save the medications DB file, replace it in the ZIP (keep a backup of the original one, though), and provide that to the restore tool in DITMM.

DITMM is a very helpful little program! That said, indeed it could do with a bulk (ideally automatic) prior-dose management/deletion feature of some kind.