# Path: newsarticles/scrapers/sentiment.py
# LOG = logging.getLogger(__name__)
# MAX_API_CALLS = floor(5000/31)  # 5000 units split over one month (31 days)
# NUM_BINS = sent_evaller().num_bins
# def analyze_all_articles():
# def get_bin_articles(current_bin):
# def bin_all_articles():
# def bin_updated_articles():
# def bin_article(article):
# def new_day(last_call_obj):
# def reset_counter(last_call_obj, max_calls=0):


import logging
from django.core.management.base import BaseCommand, CommandError
from newsarticles.scrapers import sentiment


LOG = logging.getLogger(__name__)

RUN_SCRIPT_BOTH = 'both'

class Command(BaseCommand):
    help = "Run binning and/or sentiment analysis on articles"

    def add_arguments(self, parser):
        parser.add_argument('run_script', nargs='?', default=RUN_SCRIPT_BOTH, help='Which sentiment script to run: bin all articles (binall), bin new articles (binnew), analyze articles (analyze), or both bin new and analyze (both)')

    def handle(self, *args, **options):
        if options['run_script'] == 'binall':
            LOG.info('Running binning script on all articles')
            sentiment.bin_all_articles()
        elif options['run_script'] == 'binnew':
            LOG.info('Running binning script on updated or unbinned articles')

# Path: newsarticles/scrapers/sentiment.py
# LOG = logging.getLogger(__name__)
# MAX_API_CALLS = floor(5000/31)  # 5000 units split over one month (31 days)
# NUM_BINS = sent_evaller().num_bins
# def analyze_all_articles():
# def get_bin_articles(current_bin):
# def bin_all_articles():
# def bin_updated_articles():
# def bin_article(article):
# def new_day(last_call_obj):
# def reset_counter(last_call_obj, max_calls=0):


# Path: newsarticles/management/commands/runsentiment.py
import logging
from django.core.management.base import BaseCommand, CommandError
from newsarticles.scrapers import sentiment



LOG = logging.getLogger(__name__)

RUN_SCRIPT_BOTH = 'both'

class Command(BaseCommand):
    help = "Run binning and/or sentiment analysis on articles"

    def add_arguments(self, parser):
        parser.add_argument('run_script', nargs='?', default=RUN_SCRIPT_BOTH, help='Which sentiment script to run: bin all articles (binall), bin new articles (binnew), analyze articles (analyze), or both bin new and analyze (both)')

    def handle(self, *args, **options):
        if options['run_script'] == 'binall':
            LOG.info('Running binning script on all articles')
            sentiment.bin_all_articles()
        elif options['run_script'] == 'binnew':
            LOG.info('Running binning script on updated or unbinned articles')

            sentiment.bin_updated_articles()