Skip to content

Commit

Permalink
Merge branch 'release-0.9.6.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
agnessa committed Jul 21, 2015
2 parents e78c308 + dd5caf4 commit 22c990a
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ gem 'wicked'
gem 'groupdate'
gem "chartkick"

gem 'sidekiq', '~> 3.3.0'
gem 'sidekiq', '< 3'
gem 'sidekiq-status', '~> 0.5'

gem 'whenever', :require => false
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ GEM
sass (~> 3.1)
compass-rails (1.0.3)
compass (>= 0.12.2, < 0.14)
connection_pool (2.1.0)
connection_pool (2.2.0)
coveralls (0.7.1)
multi_json (~> 1.3)
rest-client
Expand Down Expand Up @@ -233,7 +233,7 @@ GEM
jquery-ui-rails (4.1.0)
railties (>= 3.1.0)
jslint_on_rails (1.1.1)
json (1.8.1)
json (1.8.2)
json_spec (1.1.1)
multi_json (~> 1.0)
rspec (~> 2.0)
Expand Down Expand Up @@ -317,8 +317,8 @@ GEM
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
redis (3.2.0)
redis-namespace (1.5.1)
redis (3.2.1)
redis-namespace (1.5.2)
redis (~> 3.0, >= 3.0.4)
referer-parser (0.2.2)
request_store (1.0.6)
Expand Down Expand Up @@ -357,9 +357,9 @@ GEM
railties (>= 3.1)
sextant (0.2.4)
rails (>= 3.2)
sidekiq (3.3.0)
celluloid (>= 0.16.0)
connection_pool (>= 2.0.0)
sidekiq (2.17.7)
celluloid (>= 0.15.2)
connection_pool (>= 1.0.0)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
Expand Down Expand Up @@ -499,7 +499,7 @@ DEPENDENCIES
sass-rails (~> 3.2.3)
select2-rails (~> 3.5.7)
sextant
sidekiq (~> 3.3.0)
sidekiq (< 3)
sidekiq-status (~> 0.5)
simplecov
sinatra (>= 1.3.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<br /><br />
{{/if}}
{{{quota.nomenclature_note_en}}}
{{#if quota.url}}
<a class="legal-links" href="{{unbound quota.url}}">
CITES export quotas (PDF)
</a>
{{/if}}
</td>
</tr>
{{/if}}
Expand Down Expand Up @@ -68,6 +73,11 @@
<br /><br />
{{/if}}
{{{quota.nomenclature_note_en}}}
{{#if quota.url}}
<a class="legal-links" href="{{unbound quota.url}}">
CITES export quotas (PDF)
</a>
{{/if}}
</td>
</tr>
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def deactivate
protected
def collection
@eu_suspension_regulations ||= end_of_association_chain.
includes([:creator, :updater]).
order('effective_at DESC, name ASC').
page(params[:page]).
search(params[:query])
Expand Down
16 changes: 16 additions & 0 deletions app/models/eu_suspension_regulation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class EuSuspensionRegulation < Event

has_many :eu_suspensions, :foreign_key => :start_event_id,
:dependent => :destroy
has_many :ended_eu_suspensions, class_name: EuSuspension,
foreign_key: :end_event_id, dependent: :nullify

validate :designation_is_eu
validates :effective_at, :presence => true
Expand All @@ -37,6 +39,20 @@ def name_and_date
"#{self.name} (Effective from: #{self.effective_at.strftime("%d/%m/%Y")})"
end

def touch_suspensions_and_taxa
eu_suspensions = EuSuspension.where([
"start_event_id = :to_event_id OR end_event_id = :to_event_id",
to_event_id: self.id
])
eu_suspensions.update_all(
updated_at: Time.now, updated_by_id: self.updated_by_id
)
TaxonConcept.joins(:eu_suspensions).merge(eu_suspensions).update_all(
dependents_updated_at: Time.now,
dependents_updated_by_id: self.updated_by_id
)
end

private

def dependent_objects_map
Expand Down
8 changes: 4 additions & 4 deletions app/models/eu_suspension_regulation_observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ class EuSuspensionRegulationObserver < ActiveRecord::Observer
def after_create(eu_suspension_regulation)
unless eu_suspension_regulation.eu_suspensions_event_id.blank?
EventEuSuspensionCopyWorker.perform_async(
eu_suspension_regulation.eu_suspensions_event_id.to_i,
eu_suspension_regulation.eu_suspensions_event_id,
eu_suspension_regulation.id
)
DownloadsCacheCleanupWorker.perform_async(:eu_decisions)
end
end

def after_update(eu_suspension_regulation)
eu_suspension_regulation.eu_suspensions.each do |susp|
susp.touch
end
eu_suspension_regulation.touch_suspensions_and_taxa
DownloadsCacheCleanupWorker.perform_async(:eu_decisions)
end
end
2 changes: 1 addition & 1 deletion app/models/species/eu_decisions_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def initialize(filters)
@geo_entities_ids = filters[:geo_entities_ids]
@years = filters[:years]
@decision_types = filters[:decision_types]
@set = filters[:current]
@set = filters[:set]
initialize_csv_separator(filters[:csv_separator])
initialize_file_name
end
Expand Down
2 changes: 2 additions & 0 deletions app/workers/event_eu_suspension_copy_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ def perform(from_event_id, to_event_id)
#{to_event_id}
)
SQL
eu_suspension_regulation = EuSuspensionRegulation.find(to_event_id)
eu_suspension_regulation.touch_suspensions_and_taxa
end
end
11 changes: 11 additions & 0 deletions db/functions/trim_decimal_zero/20150610111751.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE OR REPLACE FUNCTION trim_decimal_zero(NUMERIC) RETURNS NUMERIC
LANGUAGE SQL IMMUTABLE
AS $$
SELECT REGEXP_REPLACE($1::TEXT,
'\.0+$',
''
)::NUMERIC
$$;

COMMENT ON FUNCTION trim_decimal_zero(NUMERIC) IS
'For display purposes make 1.0 -> 1, while 1.5 remains 1.5.';
9 changes: 9 additions & 0 deletions db/migrate/20150610111751_fix_trim_decimal_zero.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class FixTrimDecimalZero < ActiveRecord::Migration
def up
execute function_sql('20150610111751', 'trim_decimal_zero')
end

def down
execute function_sql('20150518161716', 'trim_decimal_zero')
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class ChangeVarcharsToTextInTradeDownloads < ActiveRecord::Migration
def up
change_column :trade_trade_data_downloads, :importer, :text
change_column :trade_trade_data_downloads, :exporter, :text
change_column :trade_trade_data_downloads, :origin, :text
change_column :trade_trade_data_downloads, :term, :text
change_column :trade_trade_data_downloads, :unit, :text
change_column :trade_trade_data_downloads, :source, :text
change_column :trade_trade_data_downloads, :purpose, :text
end

def down
change_column :trade_trade_data_downloads, :importer, :string
change_column :trade_trade_data_downloads, :exporter, :string
change_column :trade_trade_data_downloads, :origin, :string
change_column :trade_trade_data_downloads, :term, :string
change_column :trade_trade_data_downloads, :unit, :string
change_column :trade_trade_data_downloads, :source, :string
change_column :trade_trade_data_downloads, :purpose, :string
end
end
Binary file removed vendor/cache/connection_pool-2.1.0.gem
Binary file not shown.
Binary file added vendor/cache/connection_pool-2.2.0.gem
Binary file not shown.
Binary file removed vendor/cache/json-1.8.1.gem
Binary file not shown.
Binary file added vendor/cache/json-1.8.2.gem
Binary file not shown.
Binary file removed vendor/cache/redis-3.2.0.gem
Binary file not shown.
Binary file added vendor/cache/redis-3.2.1.gem
Binary file not shown.
Binary file removed vendor/cache/redis-namespace-1.5.1.gem
Binary file not shown.
Binary file added vendor/cache/redis-namespace-1.5.2.gem
Binary file not shown.
Binary file added vendor/cache/sidekiq-2.17.7.gem
Binary file not shown.
Binary file removed vendor/cache/sidekiq-3.3.0.gem
Binary file not shown.

0 comments on commit 22c990a

Please sign in to comment.