diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-03-16 18:13:46 +0100 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-03-16 21:20:14 +0100 |
commit | 07163593ee29b60b688205af14433588e42c6498 (patch) | |
tree | d1ea78cef8d8ef7a455d2aacc179680532c40a3d /mediagoblin/db/sql/util.py | |
parent | d8409c26a0bf40b336e036aecf3224aa74f5b8f3 (diff) | |
download | mediagoblin-07163593ee29b60b688205af14433588e42c6498.tar.lz mediagoblin-07163593ee29b60b688205af14433588e42c6498.tar.xz mediagoblin-07163593ee29b60b688205af14433588e42c6498.zip |
Create function to search media by slug.
Searching media by slug is easy on mongo. But doing the
joins in sqlalchemy is not as nice. So created a function
for doing it.
Well, and create the same function for mongo, so that it
also works.
Diffstat (limited to 'mediagoblin/db/sql/util.py')
-rw-r--r-- | mediagoblin/db/sql/util.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mediagoblin/db/sql/util.py b/mediagoblin/db/sql/util.py index efb0fafe..60024b28 100644 --- a/mediagoblin/db/sql/util.py +++ b/mediagoblin/db/sql/util.py @@ -294,6 +294,15 @@ def check_media_slug_used(dummy_db, uploader_id, slug, ignore_m_id): return does_exist +def media_entries_for_tag_slug(dummy_db, tag_slug): + return MediaEntry.query \ + .join(MediaEntry.tags_helper) \ + .join(MediaTag.tag_helper) \ + .filter( + (MediaEntry.state == u'processed') + & (Tag.slug == tag_slug)) + + def clean_orphan_tags(): q1 = Session.query(Tag).outerjoin(MediaTag).filter(MediaTag.id==None) for t in q1: |