Commit 1d8e04f3 authored by lixiaofang's avatar lixiaofang

update trans2es

parent f9b0c153
...@@ -12,8 +12,8 @@ import sys ...@@ -12,8 +12,8 @@ import sys
from libs.es import ESPerform from libs.es import ESPerform
import trans2es.models as md import trans2es.models as md
from trans2es.utils import topic_transfer from trans2es.utils import topic_transfer
from libs.table_scan import TableSlicer,TableSlicerChunk from libs.table_scan import TableSlicer, TableSlicerChunk
from trans2es.type_info import get_type_info_map,TypeInfo from trans2es.type_info import get_type_info_map, TypeInfo
from libs.cache import redis_client from libs.cache import redis_client
from trans2es.models.face_user_contrast_similar import FaceUserContrastSimilar from trans2es.models.face_user_contrast_similar import FaceUserContrastSimilar
...@@ -84,20 +84,21 @@ class SyncDataToRedis(object): ...@@ -84,20 +84,21 @@ class SyncDataToRedis(object):
class Command(BaseCommand): class Command(BaseCommand):
args = '' args = ''
help = 'dump data to elasticsearch, parallel' help = 'dump data to elasticsearch, parallel'
from optparse import make_option from optparse import make_option
option_list = BaseCommand.option_list + ( option_list = BaseCommand.option_list + (
make_option('-t', '--type', dest='type', help='type name to dump data to elasticsearch', metavar='TYPE',default=''), make_option('-t', '--type', dest='type', help='type name to dump data to elasticsearch', metavar='TYPE',
make_option('-i', '--index-prefix', dest='index_prefix', help='index name to dump data to elasticsearch', metavar='INDEX_PREFIX'), 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('-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('-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('--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('--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): def __sync_data_by_type(self, type_name):
...@@ -122,12 +123,11 @@ class Command(BaseCommand): ...@@ -122,12 +123,11 @@ class Command(BaseCommand):
for type_name in type_name_list: for type_name in type_name_list:
if len(options["type"]): 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) logging.info("begin sync [%s] data to es!" % type_name)
self.__sync_data_by_type(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() SyncDataToRedis.sync_face_similar_data_to_redis()
except: except:
......
...@@ -34,7 +34,8 @@ class ContrastSimilar(models.Model): ...@@ -34,7 +34,8 @@ class ContrastSimilar(models.Model):
try: try:
similar_user_id_list = list() similar_user_id_list = list()
if cls.objects.similarity > 0.3: 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")) content_level__in=("3", "4", "5"))
for item in query_list: for item in query_list:
if item.user_id != cls.objects.participant_user_id: 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