This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TRIGGER migrate_products AFTER UPDATE OF migrated ON products FOR EACH ROW WHEN (OLD.migrated IS NULL AND NEW.migrated IS true) EXECUTE PROCEDURE populate_referenced_entities(); | |
CREATE OR REPLACE FUNCTION batch_set_migrated() RETURNS INTEGER LANGUAGE plpgsql AS $$ | |
DECLARE batched_count INTEGER = 1; | |
BEGIN | |
WITH unmigrated_products AS ( | |
SELECT id | |
FROM products | |
WHERE migrated IS NULL | |
LIMIT 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "{SYSTEM_ID}", | |
"parent_id": "{PARENT_SYSTEM_ID}", | |
"product_type": [ "leaf" ], | |
"updated_at": "2016-04-07T12:52:03.059Z", | |
"indexed_at": "2016-04-07T13:29:54.262+00:00", | |
"created_at": "2016-04-07T13:29:54.262+00:00", | |
"list_membership": [ | |
"{SYSTEM_ID}" | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductAttribute < ActiveRecord::Base | |
include DiscriminableModel | |
uses_type_column :data_type do |data_type| | |
"#{data_type.to_s.camelize}ProductAttribute".safe_constantize | |
end | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wouldn't it be great if you could have STI like functionality | |
# without needing to encode strings of class names in the database? | |
# Well today is your lucky day! Discriminable Model is here to help. | |
# | |
# Simply specify your models desired type column, and provide a block to | |
# do the discrimination. If you want the whole STI-esque shebang of properly | |
# typed finder methods you can supply an array of 'discriminate_types' that will | |
# be used to apply an appropriate type. | |
# | |
# class MyModel < ActiveRecord::Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WorkerExtensions | |
WorkerProcess = Struct.new(:id, :name, :app_name, :size) do | |
ONE_X_WORKER_SIZE = 512.0 | |
TWO_X_WORKER_SIZE = 1024.0 | |
def memory_ceiling | |
size == 1 ? ONE_X_WORKER_SIZE : TWO_X_WORKER_SIZE | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically kill jobs' worker when it finishes | |
# if it used more memory than allotted. | |
# Ali-G: Lets talk about doctors who is ending the life of people who is suffering. | |
# Ali-G What’s it got to do with the youth in Asia I mean it aiint their fault these peoples is dying, they’s thousands of miles away. | |
# Doctor: Euthanasia means mercy killing, it literally means dying well. We're not talking about the youth in Asia, (or) the youth in Africa. | |
# Ali-G: But why is you blaming that on the asian kids or whatever? | |
module Delayed | |
module Plugins | |
class YouthInAsiaPlugin < Delayed::Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError: undefined method `meets_all_requirements?' for #<ProductExport:0x007fae799b32a8> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarkProductExportsWhichMeetAllRequirements < ActiveRecord::Migration | |
class Export < ActiveRecord::Base | |
attr_accessible :meets_requirements | |
self.inheritance_column = nil | |
def meets_all_requirements? | |
# Do some complex business logic which cannot be expressed via sql query | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarkProductExportsWhichMeetAllRequirements < ActiveRecord::Migration | |
class Export < ActiveRecord::Base | |
attr_accessible :meets_requirements | |
def meets_all_requirements? | |
# Do some complex business logic which cannot be expressed via sql query | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarkProductExportsWhichMeetAllRequirements < ActiveRecord::Migration | |
Export = Class.new(ActiveRecord::Base) | |
class ProductExport < Export | |
attr_accessible :meets_requirements | |
def meets_all_requirements? | |
# Do some complex business logic which cannot be expressed via sql query | |
end |
NewerOlder