Conversation
|
In the end I forgot to answer your issue, sorry for that. Regarding this PR - I like the idea, but... |
|
Thanks for your reply. Our system has about 4800 keys and I did not notice any lag or other issues til now. I have indeed big performance issue in startup. I have at the moment no idea why it is so slow. Never the less performance improvements are a good idea. I'll have a look. ---- edit: |
|
Despite being unsure if I understand the issue you mentioned right, I moved |
mlitwiniuk
left a comment
There was a problem hiding this comment.
@3eggert Hi, sorry for late input, but... well, I don't have proper excuse. Will you fix those "issues" and add some tests or should I fetch your changes and do it on my own? I'm ok with either
| Highly inspired by Copycopter by thoughtbot. | ||
|
|
||
| [](https://travis-ci.org/prograils/lit) | ||
| [](https://api.travis-ci.org/3eggert/lit.svg?branch=js_translations) |
There was a problem hiding this comment.
please revert that
| [](https://api.travis-ci.org/3eggert/lit.svg?branch=js_translations) | |
| [](https://travis-ci.org/prograils/lit) |
|
|
||
| def execute | ||
| @update_array.each do |a| | ||
| Lit::LocalizationKey.find(a[0]).update_columns(usage_count: a[1], used_last_at: Time.now) |
There was a problem hiding this comment.
as per my comment to Lit::Cache
| Lit::LocalizationKey.find(a[0]).update_columns(usage_count: a[1], used_last_at: Time.now) | |
| Lit::LocalizationKey.where(id: a[0]).update_all('usage_count = usage_count + ?, user_last_at = ?', a[1], Time.now) |
| @hits_counter['global_hits_counter.' + key] | ||
| end | ||
|
|
||
| def persit_global_hits_counters |
There was a problem hiding this comment.
Over time this will grow - I suggest clearing that with every call of #persit_global_hits_counters and starting from 0 again. Then PersitGlobalHitsCountersService should make db sum count with added value, rather than set it. It will also make hits counter independent of redis (ie. redis can be flushed every now and then).
| def persit_global_hits_counters | ||
| update_array = [] | ||
| @hits_counter.each do |k,v| | ||
| if k.match?(/^global_hits_counter/) |
There was a problem hiding this comment.
It might be works considering adding new method to Redis and Hash adapter, that will return all keys matching given criteria, ie. redis has this already built in: https://redis.io/commands/keys
I added a new export format which writes the translations in a js file to use it with java script.
In addition I wrote a mechanism to track which keys are actually used. The usage count and date of the last usage is written to the database and displayed in the localization view. I meant to help to delete unused keys. To enable this feature I added this config option:
# Persist global_hits_counter every 1000 lookups, set to nil or comment out to disable Lit.persit_global_hits_count = 1000I also added this config option to speed up the startup, for cases where lit is not needed:
# Initialize lit unless it ist disabled by setting the SKIP_LIT enviroment variable. Disabling is usefull to speed up the startup, for example to execute migrations Lit.init unless ENV["SKIP_LIT"] == "1"