view · edit · sidebar · attach · print · history

20110915-debug-recycle_object_error-migel

<< | Index | >>


  1. Debug Recycle object error migel
  2. Update sort function

Goal/Estimate/Evaluation:

  • Debug importer migel / 90% / 80%
Milestones
  1. Debug RangeError
  2. Debug Another error
  3. Importer job
ToDo
  • require 'migel/util/m10l_document' problem in multilingual.rb
  • require 'oddb/util/m10l_document' problem in model_super.rb

Debug Recycle object error migel

Next

  • Check which objects are sweeped in migel server side and oddb client side
  • Find how to protect the objects from GC sweeper

Note

Experiment

Possible solution

  1. kill sort function
  2. send a request every time to migel server and get the sorted object
  3. keep objects from GC somehow
  4. do not use Undumped DRbObject (call by value)

Update sort function

Concept

  • send a request everytime to get sorted objects from oddbd to migeld

Note

Idea

  1. Change the created url for sort
  2. Sort items after getting migelid object
  3. put the sortvalue key and value in the url
  4. migel server code is not necessary to be updated

Experiment

  • lib/migel/model/items.rb
  def initialize(product, sortvalue = nil)
    if product and items = product.items
      @sortvalue = sortvalue
...
  def sort_by
    # This is called at the first time when a search result is shown
    @list.sort_by do |record|
      if @sortvalue
        record.send(@sortvalue.to_sym).to_s
      else
        record.pharmacode
      end
    end
  • src/state/global.rb
      def migel_search
        if migel_code = @session.user_input(:migel_code) and product = @session.search_migel_products(migel_code).first
          #ODDB::State::Migel::Items.new(@session, ODDB::Migel::Items.new(product))
          ODDB::State::Migel::Items.new(@session, ODDB::Migel::Items.new(product, @session.user_input(:sortvalue)))
...

Access

Note

Experiment

  • src/view/migel/items.rb
  def sort_link(header_key, matrix, component)
    link = HtmlGrid::Link.new(header_key, @model, @session, self)
    link.href = @lookandfeel._event_url(:migel_search, [:migel_code, @model.first.migel_code, :sortvalue, component.to_s])
    link
  end

Access

Result

Note

Next

  • How to reverse in the 2nd click

Experiment

  • src/state/global.rb
      def migel_search
        if migel_code = @session.user_input(:migel_code) and product = @session.search_migel_products(migel_code).first
          sort_key = @session.user_input(:sortvalue) || @session.user_input(:reverse)
          reverse  = @session.user_input(:reverse)
          ODDB::State::Migel::Items.new(@session, ODDB::Migel::Items.new(product, sort_key, reverse))
  • src/model/migel/items.rb
class Items
  attr_reader :price, :qty, :unit, :pointer_descr
  def initialize(product, sortvalue = nil, reverse = nil)
    if product and items = product.items
      @sortvalue = sortvalue
      @list = items.values
      @reverse = reverse
...
  def sort_by
    # This is called at the first time when a search result is shown
    @list.sort_by do |record|
      if @sortvalue
        if @sortvalue == 'ppub'
          record.ppub.to_f
        else
          record.send(@sortvalue.to_sym).to_s
        end
      else
        record.pharmacode
      end
    end
    #reverse_sort! if @reverse
    if @reverse
      reverse_sort!
    end
    @list
  end
  • src/view/migel/items.rb
  def sort_link(header_key, matrix, component)
    link = HtmlGrid::Link.new(header_key, @model, @session, self)
    sort = @session.user_input(:sortvalue) ? :reverse : :sortvalue
    link.href = @lookandfeel._event_url(:migel_search, [:migel_code, @model.first.migel_code.gsub('.',''), sort, component.to_s])
    link
  end
  def reverse_sort!
    sort! do |a,b|
      a.send(@sortvalue.to_sym).to_s <=> b.send(@sortvalue.to_sym).to_s
    end
  end

Access

Result

  • failed
view · edit · sidebar · attach · print · history
Page last modified on September 26, 2011, at 08:32 AM