view backend/couchdb/CouchDb.py @ 206:f74fe7cb5091

when updating feeds, only ever create new Feed objects for entries that are younger than the current expire date. This ensures that we do not see old, read, expired entries again
author dirk
date Sat, 02 Jun 2012 04:30:04 +0200
parents adf7f617bda9
children bb3c851b18b1
line wrap: on
line source


from argparse import ArgumentParser

database_url = None
database = "feedworm"
design_document = database

def init():
    args = _parseArguments()
    _setDatabaseName(args)
    _setDatabaseUrl(args)
    _setDesignDocument(args)

def _parseArguments():
    parser = ArgumentParser()
    parser.add_argument("--dbname", nargs="?", help="Name of the database")
    parser.add_argument("--dburl", nargs="?", help="URL of the database")
    parser.add_argument("--designdoc", nargs="?", help="name of the feedworm design document")
    return parser.parse_known_args()

def _setDatabaseName(args):
    dbname = args[0].dbname
    if dbname is not None:
        global database
        database = dbname

def _setDatabaseUrl(args):
    dburl = args[0].dburl
    if dburl is not None:
        global database_url
        database_url = dburl

def _setDesignDocument(args):
    designDocument = args[0].designdoc
    if designDocument is not None:
        global design_document
        design_document = designDocument

#
# accessor methods for the various views
#

def feedEntriesByFeed():
    return design_document + "/feedEntries_by_feed"

def unreadFeedEntriesByFeed():
    return design_document + "/unread_feedEntries_by_feed"

def feeds():
    return design_document + "/feeds"

def feedEntryByLink():
    return design_document + "/feedEntry_by_link"

def preference():
    return design_document + "/preference"

def readFeedEntriesByCreateDate():
    return design_document + "/read_feedEntries_by_create_date"

def feedsWithUnreadEntries():
    return design_document + "/feeds_with_unread_entries"