view · edit · sidebar · attach · print · history

20110921-paging-migel-filename-bbmb

<< | Index | >>


  1. Paging function migel
  2. Update the process of setting @pages
  3. Update paging in search box result
  4. Change Bbmb order filename

Goal/Estimate/Evaluation:

  • paging migel / 100% / 100%
Milestones
  1. Paging and sorting
    1. migel_search event view
    2. Faster (update @pages setting)
    3. Switch paging and non-paging
    4. As for another searching result of product (using search box)
  2. Testcase (report, mail, compress processes)
  3. Importer job
Summary
ToDo
  • require 'migel/util/m10l_document' problem in multilingual.rb
  • require 'oddb/util/m10l_document' problem in model_super.rb

Paging function migel

Experiment

  • src/view/migel/items.rb
  def pages(model, session=@session)
    pages = @session.state.pages
    event = :migel_search
    args = {:migel_code => @session.user_input(:migel_code)}
    View::Pager.new(pages, @session, self, event, args)
  end

Run

  • bin/oddbd
  • bin/migeld

Access

Result

Note

  • Paging link works well but sort function is dead

Note

  • Now, sorting @model is implement in src/model/migel/items.rb
  • The @pages is set in src/state/migel/items.rb
  • I want to sort only the Product instances in @pages value (State::PageFacade instance), do not want to sort @model itself

Experiment

  • src/state/migel/items.rb
    class Items < State::Migel::Global include ODDB::UmlautSort VIEW = ODDB::View::Migel::Items attr_reader :pages def init
    @pages = []
    page = 0
    count = 0

    # sort here before setting @pages

    @model.each { |product|
      @pages[page] ||= ODDB::State::PageFacade.new(page)
      @pages[page].push(product)
      count += 1
      if(count >= 4)
        page += 1
        count = 0
      end
    }
    @pages[0][0], @pages[0][1] = @pages[0][1], @pages[0][0]

Access

Result

  • The order of the products does not change

Note

  • Maybe the order of @pages (PageFacade) is not related to the order of view
  • Maybe the @pages element is sorted somewhere after the setting @pages

Experiment

  • /usr/lib64/ruby/site_ruby/1.8/htmlgrid/list.rb
    def sort_model
...
#           @model = @model.sort_by(&block)

Before

After

Note

  • The page elements are sorted in the sort_model method of htmlgrid

Idea

  • Overwrite the 'sort_by(&block)' method in state/migel/items.rb

Experiment

  • src/state/migel/items.rb
module ODDB
  module State
    module Migel

class PageFacade < ODDB::State::PageFacade
  def sort_by
    self
  end
end
...
    @model.each { |product|
      @pages[page] ||= ODDB::State::Migel::PageFacade.new(page)
...
    }
    @pages[0][0], @pages[0][1] = @pages[0][1], @pages[0][0]
...

Result

Note

  • Good

Experiment (sort page elements)

  • src/state/migel/items.rb
    if sortvalue = @session.user_input(:sortvalue) || @session.user_input(:reverse)
      page.sort! do |a,b|
        if sortvalue == 'ppub'
          a.ppub.to_f <=> b.ppub.to_f
        else
          a.send(sortvalue.to_sym).to_s <=> b.send(sortvalue.to_sym).to_s
        end
      end
    end
    page.reverse! if @session.user_input(:reverse)

Access

Note

  • Good

Next

  • Large number of result

Access

Update the process of setting @pages

Problem

  • The setting of @pages variable in src/state/migel/items.rb every time when the view is shown
  • This may be a bottle neck of view

Experiment

  • src/state/migel/items.rb

Access

Note

  • The @pages setting becomes shorter and simpler
  • But actually all the product objects is kept in the cache of ch.oddb.org
  • If it should be more faster, there are two ideas
    1. cut the product objects in the model (src/model/migel/items.rb)
    2. cut the product objects in the migel server side

suspend

Update paging in search box result

  • src/view/migel/items.rb
  def pages(model, session=@session)
    pages = @session.state.pages
    event = :migel_search
    args  = {}
    if migel_code = @session.user_input(:migel_code)
      args.update({:migel_code => @session.user_input(:migel_code)})
    else
      event = :search
      args.update({
        :search_query => @session.persistent_user_input(:search_query).gsub('/', '%2F'),
        :search_type => @session.persistent_user_input(:search_type),
      })
    end
    View::Pager.new(pages, @session, self, event, args)
  end

Access

Result

  • Good

Testcases (Keep in mind)

  • src/view/migel/items.rb
  • src/state/migel/items.rb
  • src/model/migel/items.rb

Change Bbmb order filename

Email

Task

  • File name should be CO_00000...(common ID)(2 digits number)_2011mmddhhmm.dat

Experiment

  • lib/conversion/bdd_i2.rb
        def _doc_add_delivery(doc, delivery, sender_id='YWESEE')
...
            prefix = 'CO_' + "%013d" % transaction_id
  • lib/xmlconv/util/destination.rb
      def deliver_to_connection(connection, delivery, idx=nil)
...
          if(idx)
#            target.gsub!(/\.dat/, "%03i.dat" % idx)
            target.gsub!(/(CO_\d{13})/, '\0%02d' % idx )
          end

Run

  • masa@masa ~/ywesee/bbmb.ch $ bin/bbmbd
  • masa@masa ~/ywesee/globopharm.xmlconv.bbmb.ch $ bin/xmlconvd config="etc/xmlconv.yml"

Order

masa@masa ~/ywesee/globopharm.xmlconv.bbmb.ch $ cp input.xml xml_orders/

(Wait 1 minute)

Check order (FTP Server)

Result

  • filename is fine, for example CO_000000000528601_201109211640.dat

Next

  • 251 should be 000000000528601
  • 010 should be the filename including the idx

Experiment

  • lib/conversion/bdd_i2.rb
        def _doc_add_delivery(doc, delivery, sender_id='YWESEE')
...
          order.ade_id = "%013d" % transaction_id

Result

010:CO_0000000005286_201109211648.dat
251:0000000005286

Note

  • the incremental number (2 digits) should be added to both 010 and 251

Note

  • the incremental number is added just before the sending file by FTP
  • But the file contents is decided bofore the FTP sending process
  • The number of files should be counted before FTP sending process
view · edit · sidebar · attach · print · history
Page last modified on September 26, 2011, at 08:30 AM