Beispiel #1
0
def start_scheduler():
    while True:
        time_now = str(datetime.datetime.now().time())
        formatted_time = (str(int(time_now.split(':')[0]) + 2)) + ":" + (time_now.split(':')[1])
        # print(formatted_time)
        users = mongo.find_matches('users', {'datetime': formatted_time})
        for user in users:
            send_user_news(user)
        time.sleep(60)
Beispiel #2
0
def company_news_type(company_given):
    # list of news type a company has
    news_cursor = mongo.find_matches('articles', {'company': company_given})
    comp_type_of_news = []
    for new in news_cursor:
        if 'POS' in new['direction']:
            comp_type_of_news.append('good_companies')
        elif 'NEG' in new['direction']:
            comp_type_of_news.append('bad_companies')

    return list(set(comp_type_of_news))
Beispiel #3
0
def start_scheduler():
    while True:
        # utc = pytz.utc
        # utc_time = datetime.datetime.now(utc)
        # time_now = str(utc_time.now().time())
        # formatted_time = (str(int(time_now.split(':')[0]))) + ":" + (time_now.split(':')[1])
        formatted_time = datetime.datetime.utcnow().strftime("%H:%M")
        LOG.info(formatted_time)
        users = mongo.find_matches('users', {'datetime': formatted_time})
        for user in users:
            send_user_news(user)
        time.sleep(60)
Beispiel #4
0
def company_news_type(company_given, news_time):
    # list of news type a company has
    if news_time == 'all_news':
        news_cursor = mongo.find_matches('articles', {'company': company_given})
    else:
        today = datetime.date.today()
        today_date = '{}/{}/{}'.format(today.month, today.day, today.year)
        news_cursor = mongo.find_matches_two_fields('articles', 'company', [company_given],
                                                    'subtitle', [today_date])
    comp_type_of_news = []
    for new in news_cursor:
        if 'POS' in new['direction']:
            comp_type_of_news.append('good_companies')
        elif 'NEG' in new['direction']:
            comp_type_of_news.append('bad_companies')

    return list(set(comp_type_of_news))
Beispiel #5
0
def get_companies_articles(company):
    return list(mongo.find_matches('articles', {'company': company}))