Mercurial > dive4elements > framework
comparison artifact-database/src/main/resources/sql/org-postgresql-driver.properties @ 232:202b6ae2fcad
Database cleaner: Removes outdated collections, too.
artifacts/trunk@1636 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 31 Mar 2011 17:14:22 +0000 |
parents | 1ea35226a6de |
children | b35d32e507b6 |
comparison
equal
deleted
inserted
replaced
231:1ea35226a6de | 232:202b6ae2fcad |
---|---|
83 SELECT a.gid, ci.attribute FROM collection_items ci \ | 83 SELECT a.gid, ci.attribute FROM collection_items ci \ |
84 INNER JOIN artifacts a ON ci.artifact_id = a.id \ | 84 INNER JOIN artifacts a ON ci.artifact_id = a.id \ |
85 WHERE ci.collection_id IN (SELECT id FROM collections WHERE gid = ?::uuid) | 85 WHERE ci.collection_id IN (SELECT id FROM collections WHERE gid = ?::uuid) |
86 | 86 |
87 # COLLECTIONS | 87 # COLLECTIONS |
88 | |
89 collections.outdated= \ | |
90 SELECT c.id FROM collections c \ | |
91 INNER JOIN collection_items ci ON c.id = ci.collection_id \ | |
92 INNER JOIN artifacts a ON ci.artifact_id = a.id \ | |
93 WHERE c.ttl IS NOT NULL \ | |
94 AND CURRENT_TIMESTAMP - c.last_access > (c.ttl || ' microseconds')::interval \ | |
95 AND a.id NOT IN ($LOCKED_IDS$) | |
96 | |
88 collections.touch.by.gid =\ | 97 collections.touch.by.gid =\ |
89 UPDATE collections SET last_access = CURRENT_TIMESTAMP \ | 98 UPDATE collections SET last_access = CURRENT_TIMESTAMP \ |
90 WHERE gid = ?::uuid | 99 WHERE gid = ?::uuid |
91 | 100 |
92 collections.touch.by.id =\ | 101 collections.touch.by.id =\ |