# The Antville Project
# http://code.google.com/p/antville
#
# Copyright 2001–2014 by the Workers of Antville.
#
# Licensed under the Apache License, Version 2.0 (the ``License'');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an ``AS IS'' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

_children = collection(Story)
_children.local = id
_children.foreign = site_id
_children.filter = prototype = 'Story'
_children.order = created desc
_children.cacheMode = aggressive

top = collection(Story)
top.local = id
top.foreign = site_id
top.filter = prototype = 'Story' and status <> 'closed' and requests > 0
top.order = requests desc
top.maxSize = 25

featured = collection(Story)
featured.local = id
featured.foreign = site_id
featured.filter = prototype = 'Story' and status <> 'closed' and mode <> 'hidden'
featured.order = created desc

closed = collection(Story)
closed.local = id
closed.foreign = site_id
closed.filter = prototype = 'Story' and status = 'closed'
closed.order = created desc

recent = collection(Story)
recent.local = id
recent.foreign = site_id
recent.filter = prototype = 'Story' and status <> 'closed'
recent.order = modified desc
recent.maxSize = 100

comments = collection(Comment)
comments.local = id
comments.foreign = site_id
comments.filter = story.id = content.story_id and story.status <> 'closed' and \
		story.comment_mode <> 'disabled' and content.status <> 'deleted'
comments.filter.additionalTables = content as story
comments.order = content.modified desc
comments.maxSize = 100

union = collection(Story)
union.local = id
union.foreign = site_id
union.filter = status <> 'closed' and status <> 'pending' and status <> 'deleted'
union.order = modified desc
union.maxSize = 100

tags = collection(Tag)
tags.accessName = name
tags.local = id
tags.foreign = site_id
tags.order = name asc
tags.filter = tag.type = 'Story'

alphabeticalTags = collection(Tag)
alphabeticalTags.accessName = name
alphabeticalTags.local = id
alphabeticalTags.foreign = site_id
alphabeticalTags.filter = tag.type = 'Story' and \
      substr(tag.name, 1, 1) >= "A" and \
      substr(tag.name, 1, 1) <= "Z"
alphabeticalTags.group = upper(substr(tag.name, 1, 1))
alphabeticalTags.group.order = tag.name asc

otherTags = collection(Tag)
otherTags.accessName = name
otherTags.local = id
otherTags.foreign = site_id
otherTags.filter = tag.type = 'Story' and \
      substr(tag.name, 1, 1) < "A" or \
      substr(tag.name, 1, 1) > "Z"
otherTags.group = tag.name
otherTags.group.order = tag.name asc
