Commit 1d8e04f3 authored by lixiaofang's avatar lixiaofang

update trans2es

parent f9b0c153
......@@ -12,8 +12,8 @@ import sys
from libs.es import ESPerform
import trans2es.models as md
from trans2es.utils import topic_transfer
from libs.table_scan import TableSlicer,TableSlicerChunk
from trans2es.type_info import get_type_info_map,TypeInfo
from libs.table_scan import TableSlicer, TableSlicerChunk
from trans2es.type_info import get_type_info_map, TypeInfo
from libs.cache import redis_client
from trans2es.models.face_user_contrast_similar import FaceUserContrastSimilar
......@@ -84,20 +84,21 @@ class SyncDataToRedis(object):
class Command(BaseCommand):
args = ''
help = 'dump data to elasticsearch, parallel'
from optparse import make_option
option_list = BaseCommand.option_list + (
make_option('-t', '--type', dest='type', help='type name to dump data to elasticsearch', metavar='TYPE',default=''),
make_option('-i', '--index-prefix', dest='index_prefix', help='index name to dump data to elasticsearch', metavar='INDEX_PREFIX'),
make_option('-t', '--type', dest='type', help='type name to dump data to elasticsearch', metavar='TYPE',
default=''),
make_option('-i', '--index-prefix', dest='index_prefix', help='index name to dump data to elasticsearch',
metavar='INDEX_PREFIX'),
make_option('-p', '--parallel', dest='parallel', help='parallel process count', metavar='PARALLEL'),
make_option('-s', '--pks', dest='pks', help='specify sync pks, comma separated', metavar='PKS', default=''),
make_option('--streaming-slicing', dest='streaming_slicing', action='store_true', default=True),
make_option('--no-streaming-slicing', dest='streaming_slicing', action='store_false', default=True),
make_option('-S', '--sync_type',dest='sync_type', help='sync data to es',metavar='TYPE',default='')
make_option('-S', '--sync_type', dest='sync_type', help='sync data to es', metavar='TYPE', default='')
)
def __sync_data_by_type(self, type_name):
......@@ -122,12 +123,11 @@ class Command(BaseCommand):
for type_name in type_name_list:
if len(options["type"]):
if options["type"] == "all" or type_name==options["type"]:
if options["type"] == "all" or type_name == options["type"]:
logging.info("begin sync [%s] data to es!" % type_name)
self.__sync_data_by_type(type_name)
if len(options["sync_type"]) and options["sync_type"]=="sync_data_to_es":
if len(options["sync_type"]) and options["sync_type"] == "sync_data_to_es":
SyncDataToRedis.sync_face_similar_data_to_redis()
except:
......
......@@ -34,7 +34,8 @@ class ContrastSimilar(models.Model):
try:
similar_user_id_list = list()
if cls.objects.similarity > 0.3:
query_list = Topic.objects.filter(user_id=cls.objects.participant_user_id, is_deleted=False, is_online=True,
query_list = Topic.objects.filter(user_id=cls.objects.participant_user_id, is_deleted=False,
is_online=True,
content_level__in=("3", "4", "5"))
for item in query_list:
if item.user_id != cls.objects.participant_user_id:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment