Index: openacs-4/packages/photo-album/www/random-photo-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/www/random-photo-postgresql.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/photo-album/www/random-photo-postgresql.xql 27 Aug 2003 20:45:19 -0000 1.2 +++ openacs-4/packages/photo-album/www/random-photo-postgresql.xql 1 Feb 2004 22:04:16 -0000 1.3 @@ -1,66 +1,82 @@ - - postgresql7.2 + + postgresql + 7.2 + - - - + + select ci.item_id as photo_id, - (select pp.caption from pa_photos pp where pp.pa_photo_id = ci.live_revision) as caption, - i.image_id as thumb_path, - i.height as thumb_height, - i.width as thumb_width, - random() as seed - from cr_items ci, - cr_items ci2, - cr_items root, - cr_child_rels ccr2, - images i - where - $size_clause + (select pp.caption + from pa_photos pp + where pp.pa_photo_id = ci.live_revision) as caption, + i.image_id as thumb_path, + i.height as thumb_height, + i.width as thumb_width, + random() as seed + from cr_items ci, cr_items ci2, cr_child_rels ccr2, images i + where $size_clause and ci.item_id = ccr2.parent_id and ccr2.child_id = ci2.item_id and ci2.live_revision = i.image_id and ci.live_revision is not null - $folder_clause - order by seed limit 1 - - + $photo_clause + order by seed limit 1 + + + + + + select site_node__url(sn.node_id) + from site_nodes sn + inner join pa_package_root_folder_map pm on (sn.object_id = pm.package_id) + inner join cr_items parent on (pm.folder_id = parent.item_id) + inner join cr_items child on (parent.tree_sortkey <= child.tree_sortkey) + where child.tree_sortkey between parent.tree_sortkey and tree_right(parent.tree_sortkey) + and tree_level(parent.tree_sortkey) = 2 + and child.item_id = :photo_id + + + + + + select ci.item_id as photo_id, + (select pp.caption + from pa_photos pp + where pp.pa_photo_id = ci.live_revision) as caption, + i.image_id as thumb_path, + i.height as thumb_height, + i.width as thumb_width, + random() as seed + from cr_items ci, cr_items ci2, ci_items root, cr_child_rels ccr2, images i + where $size_clause + and ci.item_id = ccr2.parent_id + and ccr2.child_id = ci2.item_id + and ci2.live_revision = i.image_id + and ci.live_revision is not null + and ci.tree_sortkey between root.tree_sortkey and tree_right(root.tree_sortkey) + and root.item_id = :root_folder_id + order by seed limit 1 + + - - - select site_node__url(sn.node_id) - from site_nodes sn - inner join pa_package_root_folder_map pm on - (sn.object_id = pm.package_id) - inner join cr_items parent on - (pm.folder_id = parent.item_id) - inner join cr_items child on - (parent.tree_sortkey <= child.tree_sortkey) - where child.tree_sortkey between parent.tree_sortkey and tree_right(parent.tree_sortkey) - and tree_level(parent.tree_sortkey) = 2 - and child.item_id = :photo_id - - + + + and ci.item_id = :photo_id + + - - -and ci.tree_sortkey between root.tree_sortkey and tree_right(root.tree_sortkey) -and root.item_id = :root_folder_id - - - - - + + ccr2.relation_tag = 'viewer' - - - - - + + + + + ccr2.relation_tag = 'thumb' - - - + + +