Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: users

Use the Schwartz! (for sorting?)

 

 

Bricolage users RSS feed   Index | Next | Previous | View Threaded


phillip at communitybandwidth

Aug 19, 2008, 5:07 PM

Post #1 of 17 (5980 views)
Permalink
Use the Schwartz! (for sorting?)

Hi ho,

Brain teaser for tonight: I'm trying to sort a list of stories
returned from archive_list.mc based on the value of a sub-element of
each story returned.

Greg Heo offered this advice:

"I've done it with a regular Story->list() and then set up another hash
where the key is the field to sort by (like the date) and the value is
the story_id. Then you can just do a regular Perl sort on the key and
voila."

(He makes it sound so easy!)

Though I also found a few posts that referenced "using the
Schwartz!" (Schwartzian transform) for sorting:
http://www.gossamer-threads.com/lists/bricolage/users/5854?search_string=sorting;#5854

So, in summary, I'm in search of the best way to take the list of
stories returned from archive_list.mc and to then re-sort them, e.g.:

* Each story will have a sub-element with a value of 0 or 1 (a checkbox)
* I'd like to have stories with a sub-element value of 1 first (sorted
by their Title, descending)
* Then I'd like to have the other stories (sorted by their Title,
descending)

... before I iterate through them with the loop:

% for my $art (@$stories) {
...

Any pointers / examples appreciated.

Philip.

--
Phillip Smith,
Simplifier of Technology
Community Bandwidth
http://www.communitybandwidth.ca


lannings at who

Aug 20, 2008, 1:30 AM

Post #2 of 17 (5827 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Tue, 19 Aug 2008, Phillip Smith wrote:
> Though I also found a few posts that referenced "using the Schwartz!"
> (Schwartzian transform) for sorting:
> http://www.gossamer-threads.com/lists/bricolage/users/5854?search_string=sorting;#5854

The Schwartzian transform is for whenever you have a list
where comparing items of the list is expensive. It can also
be used (and is maybe even more commonly used) when you have
a data structure where you want to sort and get something different
than the data structure. The idea of the Schwartzian is to map
each data structure onto a copy of itself plus a part that you
want to sort by. You always have this form:

map { ... } sort { ... } map { ... } @list.

(though once you get the idea, you can easily expand
on this :).
Normally you can sort directly:

@sorted = sort @strings;
@sorted = sort { $a <=> $b } @numbers;

but with more complicated data structures, it gets more expensive
to compute the values to be compared. In your example,
where you want to find stories with checkbox fields and sort
by whether they're checked or not, it is very much appropriate
to use the Schwartzian; otherwise, you'll be extracting the checkbox
for every comparison (so you'll have like an O(N^2) instead of O(N)).

For example, say you wanted to sort stories by name. That's not too bad
using a simple sort,

@sorted = sort { $a->get_name cmp $b->get_name } @stories;

but it might be a little more efficient to do it with
a Schwartzian transform, if calling $story->get_name was expensive:

@sorted =
map { $_->[0] } # get the $story back
sort { $a->[1] cmp $b->[1] } # sort the aref by names
map { [ $_ => $_->get_name ] } # copy of $story plus name
@stories;


> * Each story will have a sub-element with a value of 0 or 1 (a checkbox)
> * I'd like to have stories with a sub-element value of 1 first (sorted by
> their Title, descending)

I leave these as exercises for the reader, haha..
But it's the same idea, just the `sort` block
is more complicated.

[sorry for any errors above, kind of rushed]


lannings at who

Aug 20, 2008, 5:34 AM

Post #3 of 17 (5840 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Wed, 20 Aug 2008, Scott Lanning wrote:
[...]
> map { ... } sort { ... } map { ... } @list.
[...]
> But it's the same idea, just the `sort` block
> is more complicated.
>
> [sorry for any errors above, kind of rushed]

Four hours later I finally read what I wrote..
and I did make at least one error:
I should've said the `map` block is more complicated
(since that's the whole point, to put the complicated
part into the map instead of the sort).
Good luck, I can help if you get stuck.


phillip at communitybandwidth

Aug 20, 2008, 6:48 AM

Post #4 of 17 (5832 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On 20-Aug-08, at 8:34 AM, Scott Lanning wrote:

> On Wed, 20 Aug 2008, Scott Lanning wrote:
> [...]
>> map { ... } sort { ... } map { ... } @list.
> [...]
>> But it's the same idea, just the `sort` block
>> is more complicated.
>>
>> [sorry for any errors above, kind of rushed]
>
> Four hours later I finally read what I wrote..
> and I did make at least one error:
> I should've said the `map` block is more complicated
> (since that's the whole point, to put the complicated
> part into the map instead of the sort).


Wow. What a thoroughly helpful post, Scott. Many thanks!


> Good luck, I can help if you get stuck.


No doubt, I'll be taking you up on that offer.

(I probably need another five cups of coffee before I can efficiently
give it a try.)

:-)

Phillip.

--
Phillip Smith,
Simplifier of Technology
Community Bandwidth
http://www.communitybandwidth.ca


acaul at rand

Jan 19, 2009, 1:00 PM

Post #5 of 17 (5329 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

Hi All. I am only a beginner Perl programmer, so I'm not very capable
of working with Schwartzian transforms from my head. I am not even
sure that the Schwartz is what I want.

What I would really like to do is to select only stories that match
certain criteria from fields defined by me, in this case an
inventory_status. If a story (which represents a product) has an
inventory_status of "Out of print" or "Removed from distribution" or
"Outdated," I do not want it to be returned by $story->list() in the
first place (if possible). Only "In stock" and "Coming soon" stories
should be returned.

Then, I want to sort these all by the document_year field, which is
not a date but rather a text field because the year is all the
information we have available for this field. Since this is neither
the cover_date nor the publish_date, I cannot use those for the Order
parameter in $story->list();

THEN (as if that were not enough), after the stories are sorted
descending by document_year, I want to sort each year by doc_title,
which is not the Bricolage title field, so I also cannot Order by
that in $story->list();

Finally, the doc_titles include words such as "A," "An," and "The,"
and we do not wish to sort on those, so the template removes those
words at the beginning of doc_title when sorting.

Right now I am doing this with a complicated series of hashes and
decision logic. This worked well for a while. Now, after four years,
the lists that are being sorted are getting much longer. The story
publish jobs keep failing because they exceed MAX_PROCESS_SIZE in
bricolage.conf. We have already updated that value several times, and
I am reluctant to continue doing so.

Thank you for any assistance you can give.

__________________________________________________________________________

This email message is for the sole use of the intended recipient(s) and
may contain confidential information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


david at kineticode

Jan 19, 2009, 1:52 PM

Post #6 of 17 (5321 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Jan 19, 2009, at 1:00 PM, Ashlee Caul wrote:

> Hi All. I am only a beginner Perl programmer, so I'm not very
> capable of working with Schwartzian transforms from my head. I am
> not even sure that the Schwartz is what I want.
>
> What I would really like to do is to select only stories that match
> certain criteria from fields defined by me, in this case an
> inventory_status. If a story (which represents a product) has an
> inventory_status of "Out of print" or "Removed from distribution" or
> "Outdated," I do not want it to be returned by $story->list() in the
> first place (if possible). Only "In stock" and "Coming soon" stories
> should be returned.

Unfortunately, I think you have to limit these in Perl space, rather
than SQL. Though you could query on

data_text => ANY('In stock', 'Coming soon')

Which will work, as long as you don't have other fields that might
have those values.

> Then, I want to sort these all by the document_year field, which is
> not a date but rather a text field because the year is all the
> information we have available for this field. Since this is neither
> the cover_date nor the publish_date, I cannot use those for the
> Order parameter in $story->list();

Correct. I do recommend you make it a date field, though, and set its
precision to year. Either way, though, yes, you will have to sort them
in the template code, and the Schwartzian transform is the most
efficient way to do so.

> THEN (as if that were not enough), after the stories are sorted
> descending by document_year, I want to sort each year by doc_title,
> which is not the Bricolage title field, so I also cannot Order by
> that in $story->list();

Right.

> Finally, the doc_titles include words such as "A," "An," and "The,"
> and we do not wish to sort on those, so the template removes those
> words at the beginning of doc_title when sorting.

Right, good.

> Right now I am doing this with a complicated series of hashes and
> decision logic. This worked well for a while. Now, after four years,
> the lists that are being sorted are getting much longer. The story
> publish jobs keep failing because they exceed MAX_PROCESS_SIZE in
> bricolage.conf. We have already updated that value several times,
> and I am reluctant to continue doing so.
>
> Thank you for any assistance you can give.

Switch to a schwartzian transform like so:

my @sorted =
map { $_->[0] }
sort { $a->[1] <=> $b->[1] || $a->[2] cmp $b->[2] }
map {
(my $title = lc $_->get_value('doc_title') ) =~ s/^(?:an?|the)
\b//;
[ $_, $_->get_value('document_year'), $title ]
} Story->list( data_text => ANY('In stock', 'Coming soon') );

HTH,

David


acaul at rand

Jan 19, 2009, 2:28 PM

Post #7 of 17 (5300 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Jan 19, 2009, at 4:52 PM, David E. Wheeler wrote:

> On Jan 19, 2009, at 1:00 PM, Ashlee Caul wrote:
>
>> Hi All. I am only a beginner Perl programmer, so I'm not very
>> capable of working with Schwartzian transforms from my head. I am
>> not even sure that the Schwartz is what I want.
>>
>> What I would really like to do is to select only stories that
>> match certain criteria from fields defined by me, in this case an
>> inventory_status. If a story (which represents a product) has an
>> inventory_status of "Out of print" or "Removed from distribution"
>> or "Outdated," I do not want it to be returned by $story->list()
>> in the first place (if possible). Only "In stock" and "Coming
>> soon" stories should be returned.
>
> Unfortunately, I think you have to limit these in Perl space,
> rather than SQL. Though you could query on
>
> data_text => ANY('In stock', 'Coming soon')
>
> Which will work, as long as you don't have other fields that might
> have those values.
>
>> Then, I want to sort these all by the document_year field, which
>> is not a date but rather a text field because the year is all the
>> information we have available for this field. Since this is
>> neither the cover_date nor the publish_date, I cannot use those
>> for the Order parameter in $story->list();
>
> Correct. I do recommend you make it a date field, though, and set
> its precision to year. Either way, though, yes, you will have to
> sort them in the template code, and the Schwartzian transform is
> the most efficient way to do so.
>
>> THEN (as if that were not enough), after the stories are sorted
>> descending by document_year, I want to sort each year by
>> doc_title, which is not the Bricolage title field, so I also
>> cannot Order by that in $story->list();
>
> Right.
>
>> Finally, the doc_titles include words such as "A," "An," and
>> "The," and we do not wish to sort on those, so the template
>> removes those words at the beginning of doc_title when sorting.
>
> Right, good.
>
>> Right now I am doing this with a complicated series of hashes and
>> decision logic. This worked well for a while. Now, after four
>> years, the lists that are being sorted are getting much longer.
>> The story publish jobs keep failing because they exceed
>> MAX_PROCESS_SIZE in bricolage.conf. We have already updated that
>> value several times, and I am reluctant to continue doing so.
>>
>> Thank you for any assistance you can give.
>
> Switch to a schwartzian transform like so:
>
> my @sorted =
> map { $_->[0] }
> sort { $a->[1] <=> $b->[1] || $a->[2] cmp $b->[2] }
> map {
> (my $title = lc $_->get_value('doc_title') ) =~ s/^(?:an?|
> the)\b//;
> [ $_, $_->get_value('document_year'), $title ]
> } Story->list( data_text => ANY('In stock', 'Coming soon') );
>
> HTH,
>
> David


Thanks. I am giving it a whirl, step by step. I started by using
data_text in $story->list to see what I get. It is returning no
stories. The widget type that includes "In stock" etc. is "Select."
Would that mean it is not the correct data type so as to be available
to the data_text param? I am sure that there are stories that match
the search criteria.


__________________________________________________________________________

This email message is for the sole use of the intended recipient(s) and
may contain confidential information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


david at kineticode

Jan 19, 2009, 2:56 PM

Post #8 of 17 (5332 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Jan 19, 2009, at 2:28 PM, Ashlee Caul wrote:

> Thanks. I am giving it a whirl, step by step. I started by using
> data_text in $story->list to see what I get. It is returning no
> stories. The widget type that includes "In stock" etc. is "Select."
> Would that mean it is not the correct data type so as to be
> available to the data_text param?

Maybe. Make sure that you specify the select values rather than the
labels.

Best,

David


lannings at who

Jan 20, 2009, 4:14 AM

Post #9 of 17 (5328 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Mon, 19 Jan 2009, Ashlee Caul wrote:
> On Jan 19, 2009, at 4:52 PM, David E. Wheeler wrote:
>> my @sorted =
>> map { $_->[0] }
>> sort { $a->[1] <=> $b->[1] || $a->[2] cmp $b->[2] }
>> map {
>> (my $title = lc $_->get_value('doc_title') ) =~ s/^(?:an?|the)\b//;
>> [ $_, $_->get_value('document_year'), $title ]
>> } Story->list( data_text => ANY('In stock', 'Coming soon') );
>
> Thanks. I am giving it a whirl, step by step. I started by using data_text
> in $story->list to see what I get. It is returning no stories.

A couple other things to keep in mind.
1) If memory is a problem, and you can't find a way to easily
filter using list, you can trade memory for CPU (and DB bandwidth)
by using list_ids and lookup.

foreach my $sid (BBAB::Story->list_ids({....})) {
my $s = BBAB::Story->lookup({id => $sid});
next unless $s matches whatever
...
}

or

grep { BBAB::Story->lookup({id=>$_}) matches whatever }
BBAB::Story->list_ids({....});

2) The Schwartzian is just a kind of shorthand name
for map -> sort -> map @list, but you can insert
grep in there too: map -> sort -> map -> grep @list .
That would not get around the list memory problem, though.
You can also use named subroutines if the sort block
is too big (perldoc -f sort).


david at kineticode

Jan 20, 2009, 8:27 AM

Post #10 of 17 (5326 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Jan 20, 2009, at 4:14 AM, Scott Lanning wrote:

> On Mon, 19 Jan 2009, Ashlee Caul wrote:
>> On Jan 19, 2009, at 4:52 PM, David E. Wheeler wrote:
>>> my @sorted =
>>> map { $_->[0] }
>>> sort { $a->[1] <=> $b->[1] || $a->[2] cmp $b->[2] }
>>> map {
>>> (my $title = lc $_->get_value('doc_title') ) =~ s/^(?:an?|
>>> the)\b//;
>>> [ $_, $_->get_value('document_year'), $title ]
>>> } Story->list( data_text => ANY('In stock', 'Coming soon') );
>>
>> Thanks. I am giving it a whirl, step by step. I started by using
>> data_text
>> in $story->list to see what I get. It is returning no stories.
>
> A couple other things to keep in mind.
> 1) If memory is a problem, and you can't find a way to easily
> filter using list, you can trade memory for CPU (and DB bandwidth)
> by using list_ids and lookup.
>
> foreach my $sid (BBAB::Story->list_ids({....})) {
> my $s = BBAB::Story->lookup({id => $sid});
> next unless $s matches whatever
> ...
> }
>
> or
>
> grep { BBAB::Story->lookup({id=>$_}) matches whatever }
> BBAB::Story->list_ids({....});

Then she can't really sort them.

Best,

David


lannings at who

Jan 20, 2009, 8:51 AM

Post #11 of 17 (5305 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Tue, 20 Jan 2009, David E. Wheeler wrote:
>> grep { BBAB::Story->lookup({id=>$_}) matches whatever }
>> BBAB::Story->list_ids({....});
>
> Then she can't really sort them.

Ah, true. Might have to stuff the grepped IDs in id=>ANY(@ids).
I just mean if saving memory (i.e. not creating all objects)
is the critical thing.


acaul at rand

Jan 27, 2009, 2:07 PM

Post #12 of 17 (5249 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Jan 19, 2009, at 4:52 PM, David E. Wheeler wrote:

> On Jan 19, 2009, at 1:00 PM, Ashlee Caul wrote:
>
>> Hi All. I am only a beginner Perl programmer, so I'm not very
>> capable of working with Schwartzian transforms from my head. I am
>> not even sure that the Schwartz is what I want.
>>
>> What I would really like to do is to select only stories that
>> match certain criteria from fields defined by me, in this case an
>> inventory_status. If a story (which represents a product) has an
>> inventory_status of "Out of print" or "Removed from distribution"
>> or "Outdated," I do not want it to be returned by $story->list()
>> in the first place (if possible). Only "In stock" and "Coming
>> soon" stories should be returned.
>
> Unfortunately, I think you have to limit these in Perl space,
> rather than SQL. Though you could query on
>
> data_text => ANY('In stock', 'Coming soon')
>
> Which will work, as long as you don't have other fields that might
> have those values.
>
>> Then, I want to sort these all by the document_year field, which
>> is not a date but rather a text field because the year is all the
>> information we have available for this field. Since this is
>> neither the cover_date nor the publish_date, I cannot use those
>> for the Order parameter in $story->list();
>
> Correct. I do recommend you make it a date field, though, and set
> its precision to year. Either way, though, yes, you will have to
> sort them in the template code, and the Schwartzian transform is
> the most efficient way to do so.
>
>> THEN (as if that were not enough), after the stories are sorted
>> descending by document_year, I want to sort each year by
>> doc_title, which is not the Bricolage title field, so I also
>> cannot Order by that in $story->list();
>
> Right.
>
>> Finally, the doc_titles include words such as "A," "An," and
>> "The," and we do not wish to sort on those, so the template
>> removes those words at the beginning of doc_title when sorting.
>
> Right, good.
>
>> Right now I am doing this with a complicated series of hashes and
>> decision logic. This worked well for a while. Now, after four
>> years, the lists that are being sorted are getting much longer.
>> The story publish jobs keep failing because they exceed
>> MAX_PROCESS_SIZE in bricolage.conf. We have already updated that
>> value several times, and I am reluctant to continue doing so.
>>
>> Thank you for any assistance you can give.
>
> Switch to a schwartzian transform like so:
>
> my @sorted =
> map { $_->[0] }
> sort { $a->[1] <=> $b->[1] || $a->[2] cmp $b->[2] }
> map {
> (my $title = lc $_->get_value('doc_title') ) =~ s/^(?:an?|
> the)\b//;
> [ $_, $_->get_value('document_year'), $title ]
> } Story->list( data_text => ANY('In stock', 'Coming soon') );
>


OK, I took your map and shuffled it a little. This is now working.

my @related_stories =
map { $_->[0] }
sort { $b->[1] <=> $a->[1] || $a->[2] cmp $b->[2] }
map {
(my $title = lc $_->get_value('doc_title') ) =~ s/^(A|An|The|Een|De|
Het) (.+)/$2, $1/i;
[ $_, $_->get_value('document_year'), $title ]
} $story->list({ contrib_id => $author_id, element_key_name =>
"book", publish_status => 1 });


The inventory_status is a select box and turned out to be a blob, so
I can't data_text it. Is there anything else I could add to the
mapping so as to return only the books that have "In stock" or
"Coming soon" as an inventory_status? (or specifically NOT to return
books with "Removed from distribution" or "Outdated" as an
inventory_status?) Thanks again.

__________________________________________________________________________

This email message is for the sole use of the intended recipient(s) and
may contain confidential information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


david at kineticode

Jan 27, 2009, 2:10 PM

Post #13 of 17 (5247 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Jan 27, 2009, at 2:07 PM, Ashlee Caul wrote:

> OK, I took your map and shuffled it a little. This is now working.
>
> my @related_stories =
> map { $_->[0] }
> sort { $b->[1] <=> $a->[1] || $a->[2] cmp $b->[2] }
> map {
> (my $title = lc $_->get_value('doc_title') ) =~ s/^(A|An|The|Een|
> De|Het) (.+)/$2, $1/i;
> [ $_, $_->get_value('document_year'), $title ]
> } $story->list({ contrib_id => $author_id, element_key_name =>
> "book", publish_status => 1 });
>
>
> The inventory_status is a select box and turned out to be a blob, so
> I can't data_text it. Is there anything else I could add to the
> mapping so as to return only the books that have "In stock" or
> "Coming soon" as an inventory_status? (or specifically NOT to return
> books with "Removed from distribution" or "Outdated" as an
> inventory_status?) Thanks again.

A select box shouldn't be a blob, but whatever. You can modify the
source to duplicate the data_text search key, adding a blob_text
search key that's identical except that it searches the blob column.
They're pretty much the same, and I would take a patch that does this,
too.

Best,

David


acaul at rand

Jan 30, 2009, 12:57 PM

Post #14 of 17 (5219 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

>>>> OK. I want to use it for something, but I don't know what I
>>>> might break in so doing. Any other thoughts?
>>>
>>> For what do you want to use it?
>>
>> I want to use it as a selection criteria on $story->list. I have
>> criterion on which to select, but $story->list can't get ahold of
>> that criterion.
>
> What? Sorry, I don't follow.


So, we established that I can't use data_text to query for items that
match "In stock" or "Coming soon" because that data is unfortunately
stored in a blob. I am thinking that if I change the priority on all
undesirable documents ("Outdated" and "Removed from distribution") to
something other than 3, then I can

$story->list({ contrib_id => $author_id, element_key_name => "book",
publish_status => 1, priority => 3 })

and so exclude the undesirable documents. Then I can feed that to the
Schwartz for the sorting.

If priority is not used for anything, then this might be ok. If
priority is used for something, I don't want to misuse it.




>> OK, I took your map and shuffled it a little. This is now working.
>>
>> my @related_stories =
>> map { $_->[0] }
>> sort { $b->[1] <=> $a->[1] || $a->[2] cmp $b->[2] }
>> map {
>> (my $title = lc $_->get_value('doc_title') ) =~ s/^(A|An|The|Een|
>> De|Het) (.+)/$2, $1/i;
>> [ $_, $_->get_value('document_year'), $title ]
>> } $story->list({ contrib_id => $author_id, element_key_name =>
>> "book", publish_status => 1 });
>>
>>
>> The inventory_status is a select box and turned out to be a blob,
>> so I can't data_text it. Is there anything else I could add to the
>> mapping so as to return only the books that have "In stock" or
>> "Coming soon" as an inventory_status? (or specifically NOT to
>> return books with "Removed from distribution" or "Outdated" as an
>> inventory_status?) Thanks again.
>
> A select box shouldn't be a blob, but whatever. You can modify the
> source to duplicate the data_text search key, adding a blob_text
> search key that's identical except that it searches the blob
> column. They're pretty much the same, and I would take a patch that
> does this, too.
>
> Best,
>
> David


__________________________________________________________________________

This email message is for the sole use of the intended recipient(s) and
may contain confidential information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


david at kineticode

Jan 30, 2009, 3:10 PM

Post #15 of 17 (5221 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Jan 30, 2009, at 12:57 PM, Ashlee Caul wrote:

> So, we established that I can't use data_text to query for items
> that match "In stock" or "Coming soon" because that data is
> unfortunately stored in a blob. I am thinking that if I change the
> priority on all undesirable documents ("Outdated" and "Removed from
> distribution") to something other than 3, then I can
>
> $story->list({ contrib_id => $author_id, element_key_name => "book",
> publish_status => 1, priority => 3 })
>
> and so exclude the undesirable documents. Then I can feed that to
> the Schwartz for the sorting.
>
> If priority is not used for anything, then this might be ok. If
> priority is used for something, I don't want to misuse it.

It can be used by users to sort documents on desks and their
workspaces. And of course they can change the priority when editing a
story. So you should establish whether or not your *users* use
priority before you go this approach. And if you, make sure it's clear
to them that they shouldn't fuck with the Priority field in any stories.

Best,

David


acaul at rand

Jan 30, 2009, 3:26 PM

Post #16 of 17 (5212 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

> On Jan 30, 2009, at 12:57 PM, Ashlee Caul wrote:
>
>> So, we established that I can't use data_text to query for items
>> that match "In stock" or "Coming soon" because that data is
>> unfortunately stored in a blob. I am thinking that if I change the
>> priority on all undesirable documents ("Outdated" and "Removed
>> from distribution") to something other than 3, then I can
>>
>> $story->list({ contrib_id => $author_id, element_key_name =>
>> "book", publish_status => 1, priority => 3 })
>>
>> and so exclude the undesirable documents. Then I can feed that to
>> the Schwartz for the sorting.
>>
>> If priority is not used for anything, then this might be ok. If
>> priority is used for something, I don't want to misuse it.
>
> It can be used by users to sort documents on desks and their
> workspaces. And of course they can change the priority when editing
> a story. So you should establish whether or not your *users* use
> priority before you go this approach. And if you, make sure it's
> clear to them that they shouldn't fuck with the Priority field in
> any stories.

OK, thanks. No one has ever used it yet, so I'm sure I can establish
this with the users.

What you mention about using the priority to sort documents on desks:
does a 1 indicate that a document is more important than a 3, or does
a 5 indicate that a document is more important than a 3?


__________________________________________________________________________

This email message is for the sole use of the intended recipient(s) and
may contain confidential information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


david at kineticode

Jan 30, 2009, 5:22 PM

Post #17 of 17 (5221 views)
Permalink
Re: Use the Schwartz! (for sorting?) [In reply to]

On Jan 30, 2009, at 3:26 PM, Ashlee Caul wrote:

> OK, thanks. No one has ever used it yet, so I'm sure I can establish
> this with the users.
>
> What you mention about using the priority to sort documents on
> desks: does a 1 indicate that a document is more important than a 3,
> or does a 5 indicate that a document is more important than a 3?

my $p = { 1 => 'High',
2 => 'Medium High',
3 => 'Normal',
4 => 'Medium Low',
5 => 'Low'
};

HTH,

David

Bricolage users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.