#!/usr/bin/env python

# -----------------------------------------------------------------------------
# Copyright (c) 2014--, The Qiita Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------

from qiita_db.util import (
    purge_filepaths, empty_trash_upload_folder, purge_files_from_filesystem)
from qiita_db.meta_util import (
    update_redis_stats, generate_biom_and_metadata_release)


# This script will perform these jobs:
# 1. purge_filepaths: remove files from that are leftover in the
#    qiita.filepath and are present in the filesystem
# 2. empty_trash_upload_folder: remove files that are present in the trash
#    of the upload folders
# 3. update_redis_stats: updates the redis stats information
# 4. generate public releases of biom tables and metadata
#
# Note that is responsability of the Qiita install system admin to add to a
# cron job this script and responsible to define how often it should run


def main():
    purge_filepaths(True)
    purge_files_from_filesystem(False)
    empty_trash_upload_folder(True)
    update_redis_stats()
    generate_biom_and_metadata_release('public')


if __name__ == "__main__":
    main()
