Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

An oddity in Loop... (Bug or Feature?)

Imagine you are SIMULTANEOUSLY creating for instance 150 articles (e.g. with category "(example)"). ['SIMULTANEOUSLY' means you have exactly same date for each articles]. Now you are creating articles with following loop:

{$ forEach 10 x in (keywordContains "(example)") $}
{$x.headline$}
{$ next $}

Everything is okay, you will get exactly 10 headlines.
Now you are modifying your loop:

{$ forEach 10 x in (keywordContains "(example)") SortDescendBy .filedDate $}
{$x.headline$}
{$ next $}

What's this? You get all 150 headlines on your page!

Is it a bug or a feature? Or am I wrong?

shpolbder
Sunday, December 14, 2003

Is this it?

http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=10702&ixReplies=1

tk
Sunday, December 14, 2003

No, they are NOT identical! I created articles from one single article, yes, but I modified them after that. Moreover, when I changed date, everyting became normal. I think it is bug, definitely.

shpolbder
Sunday, December 14, 2003

The content of the articles might be different (because you changed it), but their dates are identical. It looks like CityDesk can't sort them (since they all have the same date), so it displays them all.

When you changed the dates, CityDesk was able to sort them and things worked properly again.

You might also have been able to fix it by using modifiedDate instead of filedDate (if that still does what you wanted).

Darren Collins
Sunday, December 14, 2003

I've been hoping that time will be included the the sort. I think that would solve this problem.

tk
Sunday, December 14, 2003

I think next Citydesk release must solve this problem. I also recommend to change date a bit after creating articles or to use modified date. Too bad I speng a day to find the solution...

shpolbder
Monday, December 15, 2003

It's kind of a tricky problem. If you copy an article, what filedDate and filedTime should it have? The date/time of the original article? The date/time of when you created the copy? I can see different situations where you'd want each of these options.

There's also the problem of how CityDesk should sort articles when they have identical date/time. How do you determine what order they should list in? Maybe their order in the main window would do in this situation.

Darren Collins
Monday, December 15, 2003

In Version 1 when you copied an article, it took the filed date of the orginal article, V2 takes the current date. I don't know about the time.

tk
Monday, December 15, 2003

Darren: this way or other but to get ALL the articles on the page is incorrect. Period.

shpolbder
Monday, December 15, 2003

My version 2.0.19 release of CD keeps the creation date of the original article when I copy an article to create a new one.

geraldH
Monday, December 15, 2003

Oops, pardon me I said it backwards. In fact that is the exact problem - the only way you can create articles with identical filed dates and times.

tk
Monday, December 15, 2003

shpolbder: I understand the frustration - you've asked for say 10 articles, and 15 are coming up. It's weird and unexpected, but not entirely incorrect.

We can see why it happens. Say you asked "who's the fastest 100m runner in the school?" If two people had identical 100m times, wouldn't you be told both names? Even though you only asked for one?

As I suggested, a solution might be for CityDesk to use the order of the articles in the main window to sort them when the dates/times are identical - that way it could cut off after the first 10, as expected.

Darren Collins
Monday, December 15, 2003

That sounds like a good solution, though user-definable would be even better. Just a toggle somewhere in CityDesk.

Sort by (as defined in script) then by ___.

www.MarkTAW.com
Tuesday, December 16, 2003

Yeah, the ideal would be to allow you to sort by two fields. Then you could sort by filedDate then modifiedDate to separate the 'identical' dates.

Darren Collins
Tuesday, December 16, 2003

in fact, a "completefiledtime" field could be equal to
yyyy/mm/dd/hh/mn (computed from fileddate and filedtime) and then solve the problem.

multiple sorting could be interesting, but in that case we should be able to choose different kind of sorting per criteria:

...sortby (ascend:author;descend:completefiledtime)...

but perhaps nesting loops could be a better way to achieve that goal ?

Vincent Benard
Wednesday, December 17, 2003

*  Recent Topics

*  Fog Creek Home