Example #1
0
def find():
    resp = None
    status = 200

    try:
        query_string = request.args.copy()

        # page  = int(query_string.pop('page', 1))

        tags = None
        if not query_string:
            tags = Tag.fetch()
        else:
            tags = Tag.find(**query_string)

        resp = {'tags': tags}
    except Exception as e:
        status = 500
        resp = {"error": str(e)}

    return jsonify(resp), status
Example #2
0
    work_days = WorkDay.fetch()

    unused_tags = []
    for tag in tags:
        used = False
        for items in (entries, notes, secrets, todos, work_days):
            used = used_by(tag, items)
            if used:
                break
        if not used:
            unused_tags.append(tag)

    for tag in unused_tags:
        print(F"Pruning {tag.id:04d} - [{tag.name}].")
        tag.delete()


################################################################################
if __name__ == "__main__":
    env = os.getenv('CARTARO_ENV', 'dev')
    doc_path = os.getenv('CARTARO_DOC_PATH')
    if not doc_path:
        raise Exception("CARTARO_DOC_PATH **must** be set.")

    print(F"Analyzing Tags for {doc_path} in {env}...")

    tags = Tag.fetch()

    purge_empty(tags)
    prune_unused(tags)