Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
physical
Commits
1ab2d442
Commit
1ab2d442
authored
Jan 21, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update contrast similar
parent
cf40d59c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
1 deletion
+105
-1
contrast_similar.json
trans2es/mapping/contrast_similar.json
+14
-0
contrast_similar.py
trans2es/models/contrast_similar.py
+45
-0
type_info.py
trans2es/type_info.py
+12
-1
contrast_similar_transfer.py
trans2es/utils/contrast_similar_transfer.py
+34
-0
No files found.
trans2es/mapping/contrast_similar.json
0 → 100644
View file @
1ab2d442
{
"dynamic"
:
"strict"
,
"properties"
:
{
"id"
:{
"type"
:
"long"
},
"is_online"
:{
"type"
:
"boolean"
},
//上线
"create_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"update_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"is_deleted"
:{
"type"
:
"boolean"
},
//是否被删除
"participant_user_id"
:{
"type"
:
"long"
},
//参与者ID
"contrast_user_id_list"
:{
"type"
:
"long"
},
//对照者ID
"similarity"
:{
"type"
:
"double"
},
//相似度
}
}
\ No newline at end of file
trans2es/models/contrast_similar.py
0 → 100644
View file @
1ab2d442
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
,
CommandError
import
traceback
import
logging
from
django.db
import
models
import
datetime
from
.topic
import
Topic
manager
=
lambda
:
models
.
Manager
()
.
db_manager
(
using
=
'face'
)
class
ContrastSimilar
(
models
.
Model
):
class
Meta
:
verbose_name
=
u"用户脸相似度表"
db_table
=
"face_user_contrast_similar"
objects
=
manager
()
id
=
models
.
IntegerField
(
verbose_name
=
"主键ID"
,
primary_key
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
"是否上线"
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
"是否删除"
)
participant_user_id
=
models
.
IntegerField
(
verbose_name
=
u'参与者用户ID'
)
contrast_user_id
=
models
.
IntegerField
(
verbose_name
=
"对照者用户ID"
)
similarity
=
models
.
FloatField
(
verbose_name
=
u'相似度'
,
default
=
0
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
def
get_similar_user_id
(
self
):
try
:
similar_user_id_list
=
list
()
if
self
.
similarity
>
0.3
:
query_list
=
Topic
.
objects
.
filter
(
user_id
=
self
.
participant_user_id
,
is_deleted
=
False
,
is_online
=
True
,
content_level__in
=
(
"3"
,
"4"
,
"5"
))
for
item
in
query_list
:
if
item
.
user_id
!=
self
.
participant_user_id
:
similar_user_id_list
.
append
(
item
.
id
)
return
similar_user_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
trans2es/type_info.py
View file @
1ab2d442
...
...
@@ -12,13 +12,14 @@ import elasticsearch
import
elasticsearch.helpers
import
sys
from
trans2es.models
import
topic
,
user
,
pick_celebrity
,
group
,
celebrity
,
tag
from
trans2es.models
import
topic
,
user
,
pick_celebrity
,
group
,
celebrity
,
tag
,
contrast_similar
from
trans2es.utils.user_transfer
import
UserTransfer
from
trans2es.utils.pick_celebrity_transfer
import
PickCelebrityTransfer
from
trans2es.utils.group_transfer
import
GroupTransfer
from
trans2es.utils.topic_transfer
import
TopicTransfer
from
trans2es.utils.celebrity_transfer
import
CelebrityTransfer
from
trans2es.utils.tag_transfer
import
TagTransfer
from
trans2es.utils.contrast_similar_transfer
import
Contrast_Similar_Transfer
from
libs.es
import
ESPerform
__es
=
None
...
...
@@ -297,6 +298,16 @@ def get_type_info_map():
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'contrast_similar'
,
# facesimilar
type
=
'contrast_similar'
,
model
=
contrast_similar
.
ContrastSimilar
,
query_deferred
=
lambda
:
contrast_similar
.
ContrastSimilar
.
objects
.
all
()
.
query
,
get_data_func
=
Contrast_Similar_Transfer
.
get_contrast_similar_data
(),
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
)
]
...
...
trans2es/utils/contrast_similar_transfer.py
0 → 100644
View file @
1ab2d442
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
os
import
sys
import
logging
import
traceback
from
libs.tools
import
tzlc
import
time
from
trans2es.models.contrast_similar
import
ContrastSimilar
class
Contrast_Similar_Transfer
(
object
):
@classmethod
def
get_contrast_similar_data
(
cls
,
instance
):
try
:
res
=
dict
()
res
[
"id"
]
=
instance
.
id
res
[
"is_online"
]
=
instance
.
is_online
res
[
"is_deleted"
]
=
instance
.
is_deleted
res
[
"participant_user_id"
]
=
instance
.
participant_user_id
create_time
=
instance
.
create_time
tzlc_create_time
=
tzlc
(
create_time
)
res
[
"create_time"
]
=
tzlc_create_time
update_time
=
instance
.
update_time
tzlc_update_time
=
tzlc
(
update_time
)
res
[
"update_time"
]
=
tzlc_update_time
res
[
"similarity"
]
=
instance
.
similarity
res
[
"contrast_user_id_list"
]
=
ContrastSimilar
.
get_similar_user_id
()
return
res
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
None
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment