-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Js translations #147
base: master
Are you sure you want to change the base?
Js translations #147
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
@@ -7,7 +7,7 @@ translating app by non-technicals. | |||
|
|||
Highly inspired by Copycopter by thoughtbot. | |||
|
|||
[![travis status](https://travis-ci.org/prograils/lit.svg)](https://travis-ci.org/prograils/lit) | |||
[![travis status](https://api.travis-ci.org/3eggert/lit.svg?branch=js_translations)](https://api.travis-ci.org/3eggert/lit.svg?branch=js_translations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert that
[![travis status](https://api.travis-ci.org/3eggert/lit.svg?branch=js_translations)](https://api.travis-ci.org/3eggert/lit.svg?branch=js_translations) | |
[![travis status](https://travis-ci.org/prograils/lit.svg)](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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
@@ -143,6 +144,18 @@ def get_global_hits_counter(key) | |||
@hits_counter['global_hits_counter.' + key] | |||
end | |||
|
|||
def persit_global_hits_counters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 = 1000
I 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"