"""
@author: luojunhui
"""

from argparse import ArgumentParser

from tasks.update_published_articles_minigram_detail import UpdatePublishedArticlesMinigramDetail


def main():
    """
    update mini program detail main
    :return:
    """
    parser = ArgumentParser()
    parser.add_argument("--run-date",
                        help="Run only once for date in format of %Y-%m-%d. \
                            If no specified, run as daily jobs.")
    args = parser.parse_args()

    update_minigram_detail_task = UpdatePublishedArticlesMinigramDetail()
    update_minigram_detail_task.init_database()

    if args.run_date:
        update_minigram_detail_task.update_published_articles_job(biz_date=args.run_date)
        update_minigram_detail_task.update_mini_program_detail_job(biz_date=args.run_date)
    else:
        update_minigram_detail_task.update_published_articles_job()
        update_minigram_detail_task.update_mini_program_detail_job()


if __name__ == '__main__':
    main()