Make sure that keywords are always returned in alphabetical order in the WikiMaster byKeyword view.

This commit is contained in:
Colin Kuskie 2010-08-09 19:27:45 -07:00
parent b5ef9fc9e7
commit b8917d4e57
2 changed files with 18 additions and 14 deletions

View file

@ -552,7 +552,11 @@ sub getKeywordHierarchy {
my $datum = { my $datum = {
title => $keyword, ##Note, same as keyword title => $keyword, ##Note, same as keyword
url => $self->getUrl('func=byKeyword;keyword='.$keyword), url => $self->getUrl('func=byKeyword;keyword='.$keyword),
descendants => scalar @{ $assetKeyword->getMatchingAssets( { startAsset => $self, keyword => $keyword, }) }, descendants => scalar @{ $assetKeyword->getMatchingAssets( {
startAsset => $self,
keyword => $keyword,
sortOrder => 'Alphabetically',
}) },
}; };
##Prevent recursion if seen again ##Prevent recursion if seen again
if (! $seen->{$keyword}++) { if (! $seen->{$keyword}++) {

View file

@ -155,30 +155,30 @@ my $tag_set2 = WebGUI::VersionTag->getWorking($session);
$tag_set2->commit; $tag_set2->commit;
WebGUI::Test->addToCleanup($tag_set2); WebGUI::Test->addToCleanup($tag_set2);
cmp_bag( cmp_deeply(
$wiki->getKeywordHierarchy(), $wiki->getKeywordHierarchy(),
[ [
{ {
title => 'criminals', url => '/testwiki?func=byKeyword;keyword=criminals', title => 'criminals', url => '/testwiki?func=byKeyword;keyword=criminals',
children => bag( children => set(
superhashof({ title => 'red', }),
superhashof({ title => 'andy', }), superhashof({ title => 'andy', }),
superhashof({ title => 'red', }),
), ),
descendants => 0, descendants => 0,
}, },
{ {
title => 'inmates', url => '/testwiki?func=byKeyword;keyword=inmates', title => 'inmates', url => '/testwiki?func=byKeyword;keyword=inmates',
children => bag( children => set(
superhashof({ title => 'heywood', }),
superhashof({ title => 'brooks', }), superhashof({ title => 'brooks', }),
superhashof({ title => 'heywood', }),
), ),
descendants => 0, descendants => 0,
}, },
{ {
title => 'staff', url => '/testwiki?func=byKeyword;keyword=staff', title => 'staff', url => '/testwiki?func=byKeyword;keyword=staff',
children => bag( children => set(
superhashof({ title => 'norton', }),
superhashof({ title => 'hadley', }), superhashof({ title => 'hadley', }),
superhashof({ title => 'norton', }),
), ),
descendants => 0, descendants => 0,
}, },
@ -194,22 +194,22 @@ my $tag_set3 = WebGUI::VersionTag->getWorking($session);
$tag_set3->commit; $tag_set3->commit;
WebGUI::Test->addToCleanup($tag_set3); WebGUI::Test->addToCleanup($tag_set3);
cmp_bag( cmp_deeply(
$wiki->getKeywordHierarchy(), $wiki->getKeywordHierarchy(),
[ [
superhashof({ superhashof({
title => 'criminals', title => 'criminals',
children => bag( children => set(
superhashof({ superhashof({
title => 'andy', title => 'andy',
children => bag( children => set(
superhashof({ superhashof({
title => 'inmates', title => 'inmates',
children => bag( children => set(
superhashof({ title => 'heywood', }), superhashof({ title => 'heywood', }),
superhashof({ superhashof({
title => 'brooks', title => 'brooks',
children => bag( children => set(
superhashof({ title => 'criminals', }), superhashof({ title => 'criminals', }),
), ),
}), }),
@ -226,7 +226,7 @@ cmp_bag(
}), }),
superhashof({ superhashof({
title => 'staff', title => 'staff',
children => bag( children => set(
superhashof({ title => 'norton', }), superhashof({ title => 'norton', }),
superhashof({ title => 'hadley', }), superhashof({ title => 'hadley', }),
), ),