Esempio n. 1
0
def changed(thing):
    def _changed():
        d = dict(fullname = thing._fullname,
                 thing_type = thing._type_id)
        try:
            _change_table.insert().execute(d)
        except sa.exceptions.SQLError:
            t = _change_table
            t.update(t.c.fullname == thing._fullname,
                     values = {t.c.date: sa.func.now()}).execute()
    worker.do(_changed)
Esempio n. 2
0
def changed(thing):
    def _changed():
        d = dict(fullname = thing._fullname,
                 thing_type = thing._type_id)
        try:
            _change_table.insert().execute(d)
        except sa.exceptions.SQLError:
            t = _change_table
            t.update(t.c.fullname == thing._fullname,
                     values = {t.c.date: sa.func.now()}).execute()
    from r2.lib.solrsearch import indexed_types
    if isinstance(thing, indexed_types):
        worker.do(_changed)
Esempio n. 3
0
def changed(thing):
    def _changed():
        d = dict(fullname=thing._fullname, thing_type=thing._type_id)
        try:
            _change_table.insert().execute(d)
        except sa.exceptions.SQLError:
            t = _change_table
            t.update(t.c.fullname == thing._fullname,
                     values={
                         t.c.date: sa.func.now()
                     }).execute()

    from r2.lib.solrsearch import indexed_types
    if isinstance(thing, indexed_types):
        worker.do(_changed)
Esempio n. 4
0
def add_queries(queries, insert_item = None, delete_item = None):
    """Adds multiple queries to the query queue. If insert_item or
    delete_item is specified, the query may not need to be recomputed at
    all."""
    def _add_queries():
        for q in queries:
            if not isinstance(q, CachedResults):
                continue

            if insert_item and q.can_insert():
                q.insert(insert_item)
            elif delete_item and q.can_delete():
                q.delete(delete_item)
            else:
                query_queue.add_query(q)
    worker.do(_add_queries)
Esempio n. 5
0
def add_queries(queries, insert_item = None, delete_item = None):
    """Adds multiple queries to the query queue. If insert_item or
    delete_item is specified, the query may not need to be recomputed at
    all."""
    def _add_queries():
        for q in queries:
            if not isinstance(q, CachedResults):
                continue

            if insert_item and q.can_insert():
                q.insert(insert_item)
            elif delete_item and q.can_delete():
                q.delete(delete_item)
            else:
                query_queue.add_query(q)
    worker.do(_add_queries)
Esempio n. 6
0
def add_queries(queries, insert_items = None, delete_items = None):
    """Adds multiple queries to the query queue. If insert_items or
    delete_items is specified, the query may not need to be recomputed at
    all."""
    log = g.log.debug
    make_lock = g.make_lock
    def _add_queries():
        for q in queries:
            if not isinstance(q, CachedResults):
                continue

            with make_lock("add_query(%s)" % q.iden):
                if insert_items and q.can_insert():
                    log("Inserting %s into query %s" % (insert_items, q))
                    q.insert(insert_items)
                elif delete_items and q.can_delete():
                    log("Deleting %s from query %s" % (delete_items, q))
                    q.delete(delete_items)
                else:
                    log('Adding precomputed query %s' % q)
                    query_queue.add_query(q)
    worker.do(_add_queries)
Esempio n. 7
0
def changed(thing):
    def _changed():
        amqp.add_item('searchchanges_q', thing._fullname,
                      message_id = thing._fullname)
    worker.do(_changed)