icykoneko / ff14-fish-tracker-app

FF14 Fish Tracker App
https://ff14fish.carbuncleplushy.com
MIT License
61 stars 21 forks source link

Proposal: additional uptime mode #92

Open Lodinn opened 3 years ago

Lodinn commented 3 years ago

The reasoning here is that in deciding which fish to go after first, window frequency is oftentimes more important than "raw" uptime. I've tested it patching fish.js's uptime method with this._uptimeWindows = (crs).reduce((uptime, range) => uptime += 14400000, 0) / overallTime; or, depending on your approach to code style, a closed form this.__uptimeWindows = crs.length * 144e5 / overallTime; and it works quite fine. Not quite sure how to handle the UI toggle part though but may dig into it and make a full feature PR if you're willing to bear with me a bit in this frontend stuff :)

Lodinn commented 3 years ago

EDIT: If I'm getting this correctly, the proper way to handle this is to just add an extra option to the radio group in advanced settings and hook it up to a new sorter in sorters.js. Doesn't seem terribly complicated 😄

icykoneko commented 3 years ago

Yes, just implement as a sorter, and add another ui radio checkbox item to the <div class="row" id="sortingType"> element in index.

In the viewmodel, you'll need to update the sortingTypeChecked function to hook up the function you add to Sorters. Also in viewmodel, update the applySettings function where it checks settings.sortingType.

I think that's it.

The sorter function is essentially a comparison function. So yea, making that calculation inside of Fish::uptime would work really well since it's cached until the windows are changed.

Finally, there's the UI rows for each fish. They are using that uptime function for display purposes in FishEntry::uptime (which is a property that returns Fish::uptime. This property is read by the layout manager. Depending on the sorting type, you might want to display one value verses the other.