• View
  • Changes
  • Options
  • Related
  • Edit
  • , ,  Add +commit
     
  • View
  • Changes
  • Options
  • Related
  • Edit
  • Makes a big difference to be able to sort by more than one (e.g. +last name, +first name).

    Before doing this, it might be worth considering an even more powerful/general approach to sorting. Imagine each User has a Pointer to their high school, each of which has an address, then i'd like to be able to sort a bunch of Users by their high school's city. Again, sorting by more than one is much better (country, state/province, city).

    Also see:

    , ,  
     
     
     
     
    Related support tickets: 
    Relevant
    ...

     

  • View
  • Changes
  • Options
  • Related
  • Edit
  • sort should be able to take a hash.

     

    Here's the ruby long form for a plus card sort to sort Call cards by the content of a +call number card:

    { type: 'Call',
      sort:{
        :right=>'call_number',
        :left=>'_item', # this means the result item is the left part of the sort card. # this is the hard part, because it requires special handling based on the value # this probably has to be the value of a root-level key, and may only work for a limited set.
        :return=>'content' # this should probably be the default for anything with a cardspec
        :cast  =>'integer' # this means sort the content as numbers (1,2,3), not strings (1,10,100). Strings is default for 'content'
      }
    }

    rough version of the sql that translates to:

    select c.name, cast(s.content as integer) as sort_field from cards c left join ( select z.trunk_id, r.content from cards z join revisions r on r.card_id ...

     

    Ruby long form for sorting territories based on the number of users in them (as represented by [user]+territory)

     

    { type: 'Territory',
      sort:{
      :left =>{:type=>'User'},
      :right =>'Territory',
      :return =>'count', #not sure "return" is right word here, but it parallels normal wql usage
      :refer_to =>'_item'
      },
      :dir => 'desc'
    }

     

    and the sql:

    select c.name, coalesce(count,0) as sort_field from cards c left join ( select z.id, count(*) as count from cards z join wiki_references r on r.referenced_card_id ...

     

    You can also do variations on the current sort results.  For example, to sort a list of cards by their content numerically, you can do this:

    sort: { :return=> 'content', :cast=>'integer' }

    As for having multiple sort variables, I think at this point that becomes comparatively simple -- you just give the sort argument an array.  Eg

    sort:
    [ { :right=>'last name', :left=>'_item' },
      { :right=>'first name', :left=>'_item' }, 'update' ]

    We may also want to add shortcuts for plus card sorts, like { :sort => '+last name' }, but the full syntax is important and will have to be deduced anyway, and the shortcut conversation would probably have other higher priorities.

     

    Add +example

     

    Related support tickets: 

  • View
  • Changes
  • Options
  • Related
  • Edit
  • need to work on docs for this.  above examples are not entirely correct.  here's one eg from tests:

     

    Wql.new( :right_plus=>'*table of contents', :sort=>{ :right=>'*table_of_contents'}, :sort_as=>'integer'  )


    Given example works - http://test.dwagn.org/wagn/sorting_by_toc

     

    I see this allow for searching on things other than "right", such as "count", if you give some current-syntax ruby examples I'll probably test those too...

      --John Abbe.....Tue Nov 29 19:44:21 -0800 2011

     

    Notes

    add a note

    Download Docs Sandbox Hosting Support

  • View
  • Changes
  • Options
  • Related
  • Edit
  •  

    Wagn News

    1 to 5 of 24Next-page 1 to 5 of 24Next-page

     

    Ideas

     

     

    Support Tickets



    Wagn at github

    Wheeled by Wagn v. 1.7.2