<commit_before>from datetime import datetime, timedelta
import furl
import logging

from modularodm import Q
from modularodm.exceptions import NoResultsFound, QueryException, ImproperConfigurationError

from website import mails
from website.models import PreprintProvider
from website.settings import DOMAIN, CAMPAIGN_REFRESH_THRESHOLD


CAMPAIGNS = None
CAMPAIGNS_LAST_REFRESHED = datetime.utcnow()


def get_campaigns():

    global CAMPAIGNS
    global CAMPAIGNS_LAST_REFRESHED

    logger = logging.getLogger(__name__)

    if not CAMPAIGNS or CAMPAIGNS_LAST_REFRESHED + timedelta(seconds=CAMPAIGN_REFRESH_THRESHOLD) < datetime.utcnow():<commit_msg>Use helper method `throttle_login_exipred()`.<commit_after>from datetime import datetime
import furl
import logging

from modularodm import Q
from modularodm.exceptions import NoResultsFound, QueryException, ImproperConfigurationError

from website import mails
from website.models import PreprintProvider
from website.settings import DOMAIN, CAMPAIGN_REFRESH_THRESHOLD
from website.util.time import throttle_period_expired


CAMPAIGNS = None
CAMPAIGNS_LAST_REFRESHED = datetime.utcnow()


def get_campaigns():

    global CAMPAIGNS
    global CAMPAIGNS_LAST_REFRESHED

    logger = logging.getLogger(__name__)

    if not CAMPAIGNS or throttle_period_expired(CAMPAIGNS_LAST_REFRESHED, CAMPAIGN_REFRESH_THRESHOLD):
{'fraction_non_alphanumeric': 0.046052631578947366, 'fraction_numerical': 0.0, 'mean_word_length': 6.691011235955056, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6408807', 'n_tokens_mistral': 453, 'n_tokens_neox': 420, 'n_words': 106}