view · edit · sidebar · attach · print · history

20110928-search-faster-facebook-migel

<< | Index | >>


  1. Make alphabetical search faster migel
  2. Fix French words, Höchstvergütungsbetrag and Articlename
  3. Fix Google search link
  4. Add a Facebook 'Share' button
  5. Move 'share' button

Goal/Estimate/Evaluation:

  • speed up migel / 50% / 100%
  • fix small updates migel / 90% / 70%
Milestones
  1. faster
  2. French words migel, Höchstvergütungsbetrag (Montants Maximaux), Articlename
  3. Google search migel
  4. Facebook "Send" button in the product search result.
  5. Move 'share' button to left by Google button
  6. Remove 'FB' button
  7. Replace 'FB' to 'share' button
  8. If there is only one page, no pageing is needed:
  9. FB and Email-Link
Commit
ToDo
  1. Fix the latest kindlegen error

Make alphabetical search faster migel

Next

  • Trace back the alphabetical search process and profile the process

Experiment

  • src/util/oddbapp.rb
    def search_migel_alphabetical(query, lang)
p "getin search_migel_alphabetical"
st = Time.now
      search_method = 'search_by_name_' + lang.downcase.to_s
      if result = MIGEL_SERVER.migelid.send(search_method, query)
p Time.now - st
p "search done"
        result
      end
    end

Run

  • bin/currencyd
  • bin/oddbd
  • bin/migeld

Search

Result (Log)

"getin search_migel_alphabetical"
0.233934
"search done"

Note

  • Actually, searching itself in migel server is not a problem
  • The problem is in the process of view

Experiment

  • src/view/migel/result.rb
  def migel_code(model)
p "getin migel_code"
$st = Time.now
    #if model.respond_to?(:items) and items = model.items and !items.empty?
    if model.respond_to?(:items) and items = model.items and !items.select{|i| i.ean_code != nil and i.status != 'I'}.empty?
      link = PointerLink.new(:to_s, model, @session, self)
      link.value = model.migel_code
      link.href = @lookandfeel._event_url(:migel_search, {:migel_code => model.migel_code.gsub(/\./, '')})
p "done create link"
p Time.now - $st
      link
    else
      model.migel_code
    end
  end

Result

"getin search_migel_alphabetical"
"search done"
0.002609
"getin Migel::List#init"
0.034016
"getin migel_code"
"getin migel_code"
"getin migel_code"
"getin migel_code"
"done create link"
0.026033
"getin migel_code"
"getin migel_code"
"done create link"
0.010139
"getin migel_code"
"done create link"
0.055793
"getin migel_code"
"done create link"
7.651953
"getin migel_code"
"done create link"
15.42268
"getin migel_code"
"done create link"
1.287826
"getin migel_code"
"done create link"
0.007752
"getin migel_code"
"done create link"
0.59323
"getin migel_code"
"done create link"
0.049668
"getin migel_code"
"done create link"
7.41381
"getin migel_code"
"done create link"
0.922883
"getin migel_code"
"done create link"
0.01656
"getin migel_code"
"done create link"
3.437128
"getin migel_code"
"done create link"
0.105157
"getin migel_code"
"done create link"
0.158244
"getin migel_code"
"done create link"
0.938088
"getin migel_code"
"done create link"
1.868578
"getin migel_code"
"done create link"
0.830815
"getin migel_code"
"getin migel_code"
"getin migel_code"
"done create link"
0.016293
"getin migel_code"
"done create link"
0.018165
"getin migel_code"
"done create link"
0.007947
"getin migel_code"
"getin migel_code"
"getin migel_code"
"done create link"
0.037804
"getin migel_code"
"done create link"
0.258004
"getin migel_code"
"getin migel_code"
"getin migel_code"
"done create link"
0.007043

Note

  • Bingo
  • This is the cause
 !items.select{|i| i.ean_code != nil and i.status != 'I'}
  • This process remove out the inactive products and the products that do not have ean code

Next

  • How to select the active products suspend

Update

  • src/view/migel/result.rb
  def migel_code(model)
    #if model.respond_to?(:items) and items = model.items and !items.select{|i| i.ean_code != nil and i.status != 'I'}.empty?
    if model.respond_to?(:items) and items = model.items and !items.empty?
    # If a migelid has only inactive products, link to empty result

Note

Commit

Fix French words, Höchstvergütungsbetrag and Articlename

Update

  • src/view/migel/items.rb
class SubHeader < HtmlGrid::Composite
  COMPONENTS = {
    #[0,0,0] => 'Höchstvergütungsbetrag: ',
    [0,0,0] => :max_insure_value,
...
  def max_insure_value(model = @model, session = @session)
    if session.language == 'de'
      'Höchstvergütungsbetrag: '
    else
      'Montants Maximaux: '
    end
  end
  • src/custom/lookandfeelbase.rb
    DICTIONARIES = {
      'fr'      =>    {
        :th_article_name          =>  'Nom de produit',

Result

Fix Google search link

Updates

  • lib/migel/model/migelid.rb
      def localized_name(language)
        self.name.send(language)
      end

Note

  • This is called from src/view/addtional_information.rb#google_search

Result

  • Looks good

Add a Facebook 'Share' button

Task

  • Add a Facebook 'Share' button in the result view of migel products

Experiment

  • src/view/migel/result.rb
require 'view/facebook'
module ODDB
  module View
    module Migel

class List < HtmlGrid::List
  include View::Facebook
  def notify(model=@model, session=@session)
    facebook_share(model, session)
  end

Result

Fix share button picture and link

Reference

Experiment

  • src/view/facebook.rb
      def facebook_share(model, session=@session, share_url=nil)
        if share_url
        <<-EOS
 <a name="fb_share" share_url="#{share_url}" type="button_count" href="http://www.facebook.com/sharer.php">Share</a>
 <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
        EOS
        else
        <<-EOS
<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
        EOS
        end
      end
  • src/view/migel/result.rb def migel_code(model)
    @facebook_link = @lookandfeel._event_url(:migel_search, {:migel_product => model.migel_code.gsub(/\./, '')})
    if model.respond_to?(:items) and items = model.items and !items.empty?
    # If a migelid has only inactive products, link to empty result
      link = PointerLink.new(:to_s, model, @session, self)
      link.value = model.migel_code
      link.href = @lookandfeel._event_url(:migel_search, {:migel_code => model.migel_code.gsub(/\./, '')})
      link
    else
      model.migel_code
    end
end
  def notify(model=@model, session=@session)
    facebook_share(model, session, @facebook_link)
  end

Result

  • Link url is good, but picture and title are not set

Next

  • Picture and Title

Experiment

  • src/view/migel/product.rb
class Product < View::PrivateTemplate
  def meta_tags(context)
    super << context.meta('name' => 'title', 'content' => @model.name)
  end

Access

Result

<META name="title" content="Système de traitement par pression négative, location ">

Note

Result

  • Success!!
  • But the title is French and description is not shown

Commit

Move 'share' button

Commit

view · edit · sidebar · attach · print · history
Page last modified on September 29, 2011, at 07:18 AM