view backend/couchdb/CouchDb.py @ 258:4ca1fac32dde

Pull the constant of days to keep feed entries into the abstract class
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 12 Mar 2019 02:39:18 +0100
parents bb3c851b18b1
children
line wrap: on
line source

# -*- coding: utf-8 -*-
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"