torikushiii / hoyolab-auto

Auto check-in and others for any Hoyoverse games
https://ko-fi.com/torikushiii
GNU Affero General Public License v3.0
107 stars 24 forks source link

Issue #49 different variant #55

Closed YozenPL closed 2 months ago

YozenPL commented 3 months ago

Hello again :D

There are still something not quite right. After every "full hour" hour ZZZ stamina is not fetch from server. I used my stamina (from 240) to 140, somehow at the "full hour" it dropped down to 160 in cache (which was correct). I used some more stamina and during the next full hour I had ~86 but the script is still counting the 160 and it showing 190 now. There are no errors on the console output.

Pseudo flow of events (because I do not write down the stamina numbers at the specific hours):

  1. 240 stamina used to 140
  2. Script shown 140 at full hour
  3. 140 stamina used to 80 and it was ~86 at full hour.
  4. Script did not read the stamina from API (the ~86) and it is still counting from 160.
  5. Script shows 190 stamina.
YozenPL commented 3 months ago

Restart did not helped. I had to remove cache file to make it work.

torikushiii commented 3 months ago

I think I might know why, can you check the latest commit

YozenPL commented 3 months ago

Latest commit did not helped. Round hour has passed and it is still counting the previous value instead of fetching the right one via API.

torikushiii commented 3 months ago

should be fine at the latest commit now, its because the cache lastUpdate property is being updated so it never expires.

YozenPL commented 3 months ago

Issue remains. I already used my stamina and I have less than 90. At 20:00 CET it still counting the old value (it is showing 128). It appears that ZZZ and GI are affected.

torikushiii commented 3 months ago

does the cache file still not update if you leave it at least 1 hour?

YozenPL commented 3 months ago

I finished playing around around 18:30 so it had at least 2 chances to get the data. I instinctively deleted cache.json and restarted the application. And it fetched the data correctly.

torikushiii commented 3 months ago

little mistake at my part, should be fixed now!

YozenPL commented 3 months ago

Unfortunately no. I used all my stamina at 9:30 CET and it is showing 219 now (11:12 CET).

torikushiii commented 3 months ago

I've removed the memory cache and use the keyv cache directly since using in-memory cache is not that needed regardless, the expiration should work just fine now as shown at this image.

image

YozenPL commented 3 months ago

Not sure what is going on. At round hour (12:00 CET) value in cache changed from 240 to something like 80 (I had ~68 at that time). And now it is not adding 1 stamina per 6 minutes but 8 stamina per X mins. 84 changed to 92 then 100 and now it is showing 108 and it did it in ~30 minutes.

//EDIT: I can confirm it is adding 8 stamina per 5 minutes. I have 116 now. Could it be related to cron? I set the Stamina to 5mins. I thought it will just refresh the current value every 5 minutes and it seems that it is using this timer to make calculations?

torikushiii commented 3 months ago

can you try the latest commit again, stamina should not be abruptly increased update now as shown at the picture (cron runs every 5 minutes)

image

YozenPL commented 3 months ago

It still does by 8 points per 5 minutes for ZZZ only.

YozenPL commented 2 months ago

The problem starts after the threshold is reached. Before it, everything is fine.

torikushiii commented 2 months ago

After successfully replicating all your issue that you described i think i figured something out, this log should update correctly just like what HoYoLab does (hopefully) and the threshold you mentioned recently should be fine since at ZZZ my threshold was set at 220 and it updating correctly now.

Current time: 1724779800817
Last update time: 1724779800043
Seconds since last update: 1
Before stamina update: {
  message: '======================================',
  uid: '8058-STARRAIL',
  rate: 360,
  currentStamina: 220.5,
  maxStamina: 240,
  recoveryTime: 6717,
  secondsSinceLastUpdate: 1
}
After stamina update: {
  uid: '8058-STARRAIL',
  rate: 360,
  currentStamina: 220.5,
  maxStamina: 240,
  recoveryTime: 6716,
  message: '======================================'
}
---------------------------------------------------------------------
Current time: 1724779801394
Last update time: 1724779502687
Seconds since last update: 299
Before stamina update: {
  message: '======================================',
  uid: '1300-ZZZ',
  rate: 360,
  currentStamina: 221,
  maxStamina: 240,
  recoveryTime: 6559,
  secondsSinceLastUpdate: 299
}
After stamina update: {
  uid: '1300-ZZZ',
  rate: 360,
  currentStamina: 221.83,
  maxStamina: 240,
  recoveryTime: 6260,
  message: '======================================'
}
---------------------------------------------------------------------
Current time: 1724780100030
Last update time: undefined
Seconds since last update: 0
Before stamina update: {
  message: '======================================',
  uid: '8003-GENSHIN',
  rate: 480,
  currentStamina: 200,
  maxStamina: 200,
  recoveryTime: 0,
  secondsSinceLastUpdate: 0
}
After stamina update: {
  uid: '8003-GENSHIN',
  rate: 480,
  currentStamina: 200,
  maxStamina: 200,
  recoveryTime: 0,
  message: '======================================'
}
---------------------------------------------------------------------
Current time: 1724780101110
Last update time: 1724779800817
Seconds since last update: 301
Before stamina update: {
  message: '======================================',
  uid: '8058-STARRAIL',
  rate: 360,
  currentStamina: 220.5,
  maxStamina: 240,
  recoveryTime: 6716,
  secondsSinceLastUpdate: 301
}
After stamina update: {
  uid: '8058-STARRAIL',
  rate: 360,
  currentStamina: 221.34,
  maxStamina: 240,
  recoveryTime: 6415,
  message: '======================================'
}
---------------------------------------------------------------------
Current time: 1724780102033
Last update time: 1724779803321
Seconds since last update: 299
Before stamina update: {
  message: '======================================',
  uid: '1300-ZZZ',
  rate: 360,
  currentStamina: 122,
  maxStamina: 240,
  recoveryTime: 42259,
  secondsSinceLastUpdate: 299
}
After stamina update: {
  uid: '1300-ZZZ',
  rate: 360,
  currentStamina: 122.83,
  maxStamina: 240,
  recoveryTime: 41960,
  message: '======================================'
}
---------------------------------------------------------------------
torikushiii commented 2 months ago

Hey, can you check the latest commit and let me know if anything goes wrong again, as usual don't forget to prune your cache.json file again

torikushiii commented 2 months ago

hey, im just following up to see if everything works just as intended!

YozenPL commented 2 months ago

I tested the current version few time. It seems it is working fine. Thank you :)

torikushiii commented 2 months ago

that is good to hear!