rails / mission_control-jobs

Dashboard and Active Job extensions to operate and troubleshoot background jobs
MIT License
611 stars 71 forks source link

Simplify all times shown to not use any words, just exact numbers #184

Closed rosa closed 3 weeks ago

rosa commented 3 weeks ago

So everything is hardcoded to English, and we don't need to set a locale or have mixed-language phrases all over the place. Arguably, having the more "human-friendly" times such as "10 minutes ago" was not that useful in the end, when you're trying to get the exact time a job was enqueued to compare it with another time and so on. I found myself hovering over these times super often, so in this way, we just simplify the whole thing.

This would fix the issue described in #156 and would avoid having to mess up with locales.

matthewbjones commented 6 days ago

@rosa, are you open to this being a config option? We actually found the English words a lot more useful than what it is now currently doing. When looking at "In Progress jobs", now there are just a bunch of date/times in UTC, and you no longer can easily see how long a job as been running for.

Also we now find that the "Recurring tasks" tab is less helpful, as it is just displaying date/times in UTC, and now it is not easy to determine "how long ago" a job ran, and how long until it'll run again, etc.

We actually liked that you could hover over the words and see the date/time if you needed.

rosa commented 6 days ago

@matthewbjones yeah, that's a good point; we've been using this for a bit now in production, and I find myself also missing the words 😅 The problem is the annoyance with the locale, having to set it to English and then having to do ugly stuff to avoid crashing when English is not available 😅 I didn't like that code at all.

I basically want a way to use the words helpers but force them to be in English without even bothering to check the locale 😆 This doesn't seem possible in Rails right now... but maybe we can do something around it... I think a config option for this is too heavy... let me think about it a bit more.

matthewbjones commented 6 days ago

@rosa I can try to work on this. FWIW, I forked and reverted https://github.com/rails/mission_control-jobs/commit/514e2b5d8c0740c49b7276aa28aed18456ea4ebe without reverting https://github.com/rails/mission_control-jobs/commit/56a4223cb1e640cc89f0d08c9d310a0b314af02f, and the UI still works in English, and the full test suite passes.

I'll play around with things in my fork. I agree, ideally, it would "just work" without any config options.

matthewbjones commented 6 days ago

@rosa Rails can be configured to fallback to another locale when translations are missing: https://guides.rubyonrails.org/v5.2.0/configuring.html#configuring-i18n

So without forcing a locale (aka, reverting https://github.com/rails/mission_control-jobs/commit/56a4223cb1e640cc89f0d08c9d310a0b314af02f), you can run Mission Control in a Rails app with non-English locale set as the default, and have the usual "Translation missing: de.datetime.distance_in_words.x_days ago" message, but if in the Rails app you do config.i18n.fallbacks = [:en], (or within Mission Control the code does I18n.fallbacks = [:en], then Mission Control still shows English time words.

I'm just now trying to play around with the idea of the fallbacks support with I18n and see if there is an around_action of sorts that can take advantage. I'm guessing setting I18n.fallbacks = [:en] could have unintended side effects in the Rails app (if Mission Control did that itself)

matthewbjones commented 3 days ago

@rosa Unfortunately, I wasn't able to come up with a simple/elegant solution

rosa commented 3 days ago

No worries @matthewbjones, and sorry I missed your last comment!

So without forcing a locale (aka, reverting https://github.com/rails/mission_control-jobs/commit/56a4223cb1e640cc89f0d08c9d310a0b314af02f), you can run Mission Control in a Rails app with non-English locale set as the default

Yes! That was the first problem we had, because the UI would show mixed languages, English for the hardcoded parts, and whatever locale was set for the texts added by Rails when using the time helpers 😅 https://github.com/rails/mission_control-jobs/issues/136 . The example there was "enqueued 5 minuten ago". The solution for that was to set English as the locale for Mission Control, but then, that caused trouble for people who don't have English in their locale list: https://github.com/rails/mission_control-jobs/pull/156 😅

This is why I don't want to mess up with locales, what I'd like here is that the Rails time helpers would use always English words, like hours, minutes, seconds, etc. and not, say, horas, minutos, segundos, which would be all mixed with English words. I haven't spent enough time investigating if there's a way to do this. I had a quick look last week and it doesn't seem so.