def handle_notices_diff(notices): notices_coll = mc.get_default_database().notices different_notices = [] print 'Checking ', len(notices), 'notices' for notice in notices: sanitised_notice = sanitise_notice_for_database(notice) notice_cpy = shallow_copy(sanitised_notice) try: del notice_cpy['uid'] except KeyError: pass db_notice = notices_coll.find_one( {'$or': [{ 'uid': sanitised_notice['uid'] }, notice_cpy]}) if db_notice is None: different_notices.append(notice) print 'Different notices: ', [ sanitise_notice_for_database(notice) for notice in different_notices ] if len(different_notices) > 0: for notice in different_notices: sanitised_notice = sanitise_notice_for_database(notice) hooks.notices_updated([notice]) notices_coll.insert_one(sanitised_notice)
def handle_notices_diff(notices): notices_coll = mc.get_default_database().notices different_notices = [] print 'Checking ', len(notices), 'notices' for notice in notices: db_notice = notices_coll.find_one(notice) if db_notice is None: different_notices.append(notice) print 'Different notices: ', different_notices if len(different_notices) > 0: for notice in different_notices: hooks.notices_updated([notice]) notices_coll.insert_one(notice)