Esempio n. 1
0
def update_index():
    """
    Update the search index with the new emails since the last index update.
    """
    update_cmd = UpdateIndexCommand()
    # Find the last email in the index:
    try:
        last_email = SearchQuerySet().latest('archived_date')
    except Exception: # pylint: disable-msg=broad-except
        # Different backends can raise different exceptions unfortunately
        update_cmd.start_date = None
    else:
        update_cmd.start_date = last_email.object.archived_date
    # set defaults
    update_cmd.verbosity = 0
    update_cmd.batchsize = None
    update_cmd.end_date = None
    update_cmd.workers = 0
    # Setting remove to True is extremely slow, it needs to scan the entire
    # index and database. About 15 minutes on Fedora's lists, so not for a
    # frequent operation.
    update_cmd.remove = False
    update_cmd.update_backend("hyperkitty", "default")
Esempio n. 2
0
def update_index(remove=False):
    """
    Update the search index with the new emails since the last index update.

    Setting remove to True is extremely slow, it needs to scan the entire
    index and database. It takes about 15 minutes on Fedora's lists, so it is
    not fit for a frequent operation.
    """
    update_cmd = UpdateIndexCommand()
    # Find the last email in the index:
    try:
        last_email = SearchQuerySet().latest('archived_date')
    except Exception:
        # Different backends can raise different exceptions unfortunately
        update_cmd.start_date = None
    else:
        update_cmd.start_date = last_email.archived_date
    # set defaults
    update_cmd.verbosity = 0
    update_cmd.batchsize = None
    update_cmd.end_date = None
    update_cmd.workers = 0
    update_cmd.commit = True
    update_cmd.remove = remove
    try:
        from haystack.management.commands.update_index import \
            DEFAULT_MAX_RETRIES
    except ImportError:
        pass
    else:
        update_cmd.max_retries = DEFAULT_MAX_RETRIES
    update_cmd.update_backend("hyperkitty", "default")
def update_index(remove=False, listname=None, verbosity=0):
    """
    Update the search index with the new emails since the last index update
    or if listname is provided, with all emails from that list.

    Setting remove to True is extremely slow, it needs to scan the entire
    index and database. It takes about 15 minutes on Fedora's lists, so it is
    not fit for a frequent operation.

    The listname option is intended to update a single list after importing
    that list's archives.  Doing the entire archive takes way too long and
    doing a 'since' doesn't get the old imported posts.
    """
    global LISTNAME
    LISTNAME = listname
    update_cmd = UpdateIndexCommand()
    if LISTNAME is None:
        # Find the last email in the index:
        try:
            last_email = SearchQuerySet().latest('archived_date')
        except Exception:
            # Different backends can raise different exceptions unfortunately
            update_cmd.start_date = None
        else:
            update_cmd.start_date = last_email.archived_date
    else:
        # Is this a valid list?
        try:
            get_object_or_404(MailingList, name=listname)
        except Http404 as e:
            raise CommandError('{}: {}'.format(listname, e))
        # set the start date to None to do the whole list.
        update_cmd.start_date = None
    # set defaults
    update_cmd.verbosity = verbosity
    update_cmd.batchsize = None
    update_cmd.end_date = None
    update_cmd.workers = 0
    update_cmd.commit = True
    update_cmd.remove = remove
    try:
        from haystack.management.commands.update_index import (
            DEFAULT_MAX_RETRIES)
    except ImportError:
        pass
    else:
        update_cmd.max_retries = DEFAULT_MAX_RETRIES
    update_cmd.update_backend("hyperkitty", "default")
Esempio n. 4
0
def update_index(remove=False):
    """
    Update the search index with the new emails since the last index update.

    Setting remove to True is extremely slow, it needs to scan the entire
    index and database. It takes about 15 minutes on Fedora's lists, so it is
    not fit for a frequent operation.
    """
    update_cmd = UpdateIndexCommand()
    # Find the last email in the index:
    try:
        last_email = SearchQuerySet().latest('archived_date')
    except Exception: # pylint: disable-msg=broad-except
        # Different backends can raise different exceptions unfortunately
        update_cmd.start_date = None
    else:
        update_cmd.start_date = last_email.archived_date
    # set defaults
    update_cmd.verbosity = 0
    update_cmd.batchsize = None
    update_cmd.end_date = None
    update_cmd.workers = 0
    update_cmd.commit = True
    update_cmd.remove = remove
    try:
        from haystack.management.commands.update_index import \
            DEFAULT_MAX_RETRIES
    except ImportError:
        pass
    else:
        update_cmd.max_retries = DEFAULT_MAX_RETRIES
    update_cmd.update_backend("hyperkitty", "default")