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
alpha
physical
Commits
30688c82
Commit
30688c82
authored
Nov 24, 2018
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
42e439b6
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
190 additions
and
4 deletions
+190
-4
__init__.py
search/views/__init__.py
+0
-0
topic.py
search/views/topic.py
+63
-0
trans2es_data2es_parallel.py
trans2es/management/commands/trans2es_data2es_parallel.py
+9
-1
user.json
trans2es/mapping/user.json
+6
-1
group_user_role.py
trans2es/models/group_user_role.py
+0
-0
pickuserrecord.py
trans2es/models/pickuserrecord.py
+26
-0
topic.py
trans2es/models/topic.py
+2
-1
user.py
trans2es/models/user.py
+42
-0
user_follow.py
trans2es/models/user_follow.py
+26
-0
type_info.py
trans2es/type_info.py
+12
-1
user_transfer.py
trans2es/utils/user_transfer.py
+4
-0
No files found.
search/views/__init__.py
0 → 100644
View file @
30688c82
search/views/topic.py
0 → 100644
View file @
30688c82
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
gm_rpcd.all
import
bind
import
logging
import
traceback
@bind
(
"physical/search/home_recommend"
)
def
home_recommend
(
user_id
=-
1
):
"""
:remark:首页推荐,目前只推荐日记
:return:
"""
try
:
# 获取user_id 关注的用户集合
attention_user_id_list
=
list
()
# 获取user_id pick的用户集合
pick_user_id_list
=
list
()
# 参与的小组发帖
# 马甲账号集合
vest_account_list
=
list
()
q
=
dict
()
q
[
"filter"
]
=
{
"range"
:{
"content_level"
:{
"gte"
:
3
,
"lte"
:
5
}}
}
query_function_score
=
dict
()
functions
=
[
{
"filter"
:{
"match"
:{
"user_id"
:
attention_user_id_list
}},
"weight"
:
5
,
},
{
"filter"
:{
"match"
:{
"user_id"
:
pick_user_id_list
}},
"weight"
:
3
},
{
"filter"
:
{
"match"
:
{
"user_id"
:
vest_account_list
}},
"weight"
:
0.5
},
{
"filter"
:{
"match"
:{
"content_level"
:
5
}},
"weight"
:
5
},
{
"filter"
:{
"match"
:{
"content_level"
:
4
}},
"weight"
:
3
},
{
"filter"
:{
"match"
:{
"content_level"
:
3
}},
"weight"
:
2
}
]
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
trans2es/management/commands/trans2es_data2es_parallel.py
View file @
30688c82
...
...
@@ -50,7 +50,7 @@ class Command(BaseCommand):
from
optparse
import
make_option
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'-t'
,
'--type'
,
dest
=
'type_list'
,
action
=
'append'
,
help
=
'type name to dump data to elasticsearch'
,
metavar
=
'TYPE'
),
make_option
(
'-t'
,
'--type'
,
dest
=
'type_list'
,
action
=
'append'
,
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
=
''
),
...
...
@@ -60,9 +60,17 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
try
:
option_type_list
=
list
()
if
len
(
self
.
option_list
.
type_list
)
>
0
:
option_type_list
=
self
.
option_list
.
type_list
.
split
(
","
)
type_name_list
=
get_type_info_map
()
.
keys
()
for
type_name
in
type_name_list
:
if
type_name
not
in
option_type_list
:
logging
.
warning
(
"type_name:
%
s can not need to execute!"
%
type_name
)
continue
type_info
=
get_type_info_map
()[
type_name
]
query_set
=
type_info
.
queryset
...
...
trans2es/mapping/user.json
View file @
30688c82
...
...
@@ -3,6 +3,10 @@
"properties"
:
{
"id"
:{
"type"
:
"long"
},
"name"
:{
"type"
:
"text"
},
"icon"
:{
"type"
:
"text"
}
"icon"
:{
"type"
:
"text"
},
"tag_list"
:{
"type"
:
"string"
},
"attention_user_id_list"
:{
"type"
:
"string"
},
"pick_user_id_list"
:{
"type"
:
"string"
},
"same_group_user_id_list"
:{
"type"
:
"string"
}
}
}
\ No newline at end of file
trans2es/models/group_user_role.py
0 → 100644
View file @
30688c82
trans2es/models/pickuserrecord.py
0 → 100644
View file @
30688c82
#!/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
libs.es
import
ESPerform
from
django.db
import
models
import
datetime
from
.user
import
User
class
PickUserRecord
(
models
.
Model
):
class
Meta
:
verbose_name
=
u'pickuserrecord'
verbose_name_plural
=
u'pickuserrecord'
db_table
=
'pickuserrecord'
app_label
=
'api'
pickuser_id
=
models
.
IntegerField
(
verbose_name
=
"pick user id"
)
#user_id = models.IntegerField(verbose_name="用户ID")
is_deleted
=
models
.
BooleanField
(
verbose_name
=
"是否删除"
)
is_pick
=
models
.
BooleanField
(
verbose_name
=
"is_pick"
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'日记创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'日记更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
user
=
models
.
ForeignKey
(
User
,
related_name
=
"user_pick"
,
verbose_name
=
"pick用户信息"
)
trans2es/models/topic.py
View file @
30688c82
...
...
@@ -16,10 +16,11 @@ class Topic(models.Model):
db_table
=
'topic'
app_label
=
'api'
group_
id
=
models
.
IntegerField
(
verbose_name
=
'日记ID'
)
id
=
models
.
IntegerField
(
verbose_name
=
'日记ID'
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'日记创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'日记更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
name
=
models
.
CharField
(
verbose_name
=
'日记名称'
)
group_id
=
models
.
IntegerField
(
verbose_name
=
'用户所在组ID'
)
user_id
=
models
.
IntegerField
(
verbose_name
=
'用户ID'
)
description
=
models
.
CharField
(
verbose_name
=
'日记本描述'
)
content
=
models
.
CharField
(
verbose_name
=
'日记本内容'
)
...
...
trans2es/models/user.py
0 → 100644
View file @
30688c82
#!/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
libs.es
import
ESPerform
from
django.db
import
models
import
datetime
class
User
(
models
.
Model
):
class
Meta
:
verbose_name
=
u'用户'
verbose_name_plural
=
u'用户'
db_table
=
'user'
app_label
=
'api'
id
=
models
.
IntegerField
(
verbose_name
=
"用户ID"
)
name
=
models
.
CharField
(
verbose_name
=
"用户名称"
)
icon
=
models
.
CharField
(
verbose_name
=
''
)
def
get_follow_user_id_list
(
self
):
follow_user_id_list
=
list
()
user_follows
=
self
.
user_follow
.
filter
(
is_online
=
True
)
for
user_follow
in
user_follows
:
follow_user_id_list
.
append
(
user_follow
.
follow_id
)
return
follow_user_id_list
def
get_pick_user_id_list
(
self
):
pick_user_id_list
=
list
()
user_picks
=
self
.
user_pick
.
filter
(
is_deleted
=
False
)
for
user_pick
in
user_picks
:
pick_user_id_list
.
append
(
user_pick
.
pickuser_id
)
return
pick_user_id_list
trans2es/models/user_follow.py
0 → 100644
View file @
30688c82
#!/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
libs.es
import
ESPerform
from
django.db
import
models
import
datetime
from
.user
import
User
class
UserFollow
(
models
.
Model
):
class
Meta
:
verbose_name
=
u'用户关注'
verbose_name_plural
=
u'用户关注'
db_table
=
'user_follow'
app_label
=
'api'
#user_id = models.IntegerField(verbose_name="用户ID")
user
=
models
.
ForeignKey
(
User
,
related_name
=
"user_follow"
,
verbose_name
=
"关注用户信息"
)
follow_id
=
models
.
IntegerField
(
verbose_name
=
"关注的用户ID"
)
is_online
=
models
.
BooleanField
(
verbose_name
=
"是否上线"
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
"是否删除"
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'日记创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'日记更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
trans2es/type_info.py
View file @
30688c82
...
...
@@ -12,8 +12,9 @@ import elasticsearch
import
elasticsearch.helpers
import
sys
from
trans2es.models
import
topic
from
trans2es.models
import
topic
,
user
from
trans2es.utils.topic_transfer
import
TopicTransfer
from
trans2es.utils.user_transfer
import
UserTransfer
from
libs.es
import
ESPerform
...
...
@@ -242,6 +243,16 @@ def get_type_info_map():
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
"user"
,
#用户
type
=
"user"
,
model
=
user
.
User
,
query_deferred
=
lambda
:
user
.
User
.
objects
.
all
()
.
query
,
get_data_func
=
UserTransfer
.
get_user_data
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
)
]
...
...
trans2es/utils/user_transfer.py
View file @
30688c82
...
...
@@ -16,6 +16,10 @@ class UserTransfer(object):
res
[
"id"
]
=
instance
.
id
res
[
"icon"
]
=
instance
.
icon
res
[
"name"
]
=
instance
.
name
res
[
"tag_list"
]
=
""
res
[
"attention_user_id_list"
]
=
instance
.
get_follow_user_id_list
res
[
"pick_user_id_list"
]
=
instance
.
pick_user_id_list
res
[
"same_group_user_id_list"
]
=
""
return
res
except
:
...
...
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