Skip to content

Adds #172 - Option to touch localizations #173

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

Merged
merged 2 commits into from
Apr 26, 2021

Conversation

mlitwiniuk
Copy link
Member

Adds options to allow "touching" localizations in batch - this is useful for situations with synchronizations. All "touched" localizations will be for sure subject of next synchronization.
Screenshot 2021-04-23 at 14 34 10
Screenshot 2021-04-23 at 14 34 20
Screenshot 2021-04-23 at 14 34 26

@mlitwiniuk mlitwiniuk requested a review from pnikrat April 23, 2021 12:36
end

def localization_for(locale, localization_key)
@_localization_for ||= {}
key = [locale, localization_key]
ret = @_localization_for[key]
binding.pry if localization_key == 'scopes.string'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove before merging

if ret == false
nil
elsif ret.nil?
ret = grouped_localizations[localization_key][locale]
unless ret
::Rails.logger.info "******** REFRESHING the key"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it part of previous PR when you tried to reproduce ret being false or is it relevant for this PR?

<td>
<% if localization %>
<%= draw_icon 'clock-o', title: "Last updated at #{localization.updated_at.to_s(:db)}" %>
<%= link_to lit.previous_versions_localization_key_localization_path(lk, localization, format: :js), class: "show_prev_versions #{'hidden' unless versions?(localization)}", remote: true do %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show_prev_versions -> js-show-prev-versions as it's not used for styling, just for targeting via jquery in one of js.erb actions

v.update_column :updated_at, 1.day.ago
a.update_column :updated_at, 1.day.ago
post :batch_touch, params: { key: 'value' }, format: :js
assert v.reload.updated_at > 1.second.ago
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found asserting two time values to be much more reliable by using this assertion:
assert_in_delta(v.reload.updated_at, 1.second.ago, 5) where 5 means 5 seconds (delta).
Otherwise we may face flaky test failures in the future. You can assign some constant to 5 or leave the magic number, it's not that important in tests :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this syntax would allow you to use 1.day.ago instead of 23.hours.ago to be more clear that we are asserting that a.updated_at did not change

@mlitwiniuk mlitwiniuk merged commit 8baf2a9 into master Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants