Class: MoveToGo::ShardHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/move-to-go/shard_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shard_size = nil) ⇒ ShardHelper

Returns a new instance of ShardHelper.



6
7
8
9
# File 'lib/move-to-go/shard_helper.rb', line 6

def initialize(shard_size = nil)
    @shard_size = shard_size || 25000
    setup()
end

Instance Attribute Details

#current_shardObject

Returns the value of attribute current_shard.



4
5
6
# File 'lib/move-to-go/shard_helper.rb', line 4

def current_shard
  @current_shard
end

#current_shard_countObject

Returns the value of attribute current_shard_count.



4
5
6
# File 'lib/move-to-go/shard_helper.rb', line 4

def current_shard_count
  @current_shard_count
end

#shardsObject

Returns the value of attribute shards.



4
5
6
# File 'lib/move-to-go/shard_helper.rb', line 4

def shards
  @shards
end

Instance Method Details

#shard_model(model) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/move-to-go/shard_helper.rb', line 11

def shard_model(model)
    @current_shard.settings = model.settings

    model.coworkers.each{ |key, coworker|
        if coworker.integration_id != "migrator"
            add_coworker(coworker)
        end
    }
    model.organizations.each{|key, org| add_organization(org)}
    model.deals.each{|key, deal| add_deal(deal)}
    model.histories.each{|key, history| add_history(history)}
    model.todos.each{|key, todo| add_todo(todo)}
    model.meetings.each{|key, meeting| add_meeting(meeting)}
    add_documents(model.documents)

    return_value = @shards
    setup()
    return return_value
end