-
Notifications
You must be signed in to change notification settings - Fork 0
/
datawatcher.py
246 lines (201 loc) · 7.44 KB
/
datawatcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import time
import torndb as mysqldb
import traceback
import os
import sys
import sched
from setting.setting import host, dbname, dbuser, password
#from setting.setting import recommend_member
from sendcloud import sendemail
from sendcloud import sendmessage
class Db(object):
def __init__(self):
try:
self.db = mysqldb.Connection(host,dbname,dbuser,password)
except Exception, e:
print traceback.print_exc()
return
def membersmall5(self,exist_recommend):
'''
需要重新考虑完全没有推荐的人
_db_data2部分
'''
try:
_db_data1 = self.db.query('select name,telephone,email \
from customer_member_t where is_open_recommend = 1 \
and resume_review_status=10 and member_id in \
(select customer_id from bussiness_member_recommend \
group by customer_id having count(*) <= 5) order by member_id;')
_db_data2 = self.db.query('select name,email,telephone from \
customer_member_t where member_id not in \
(select customer_id from bussiness_member_recommend ) \
and is_open_recommend = 1 and resume_review_status=10;')
except Exception, e:
print traceback.print_exc()
return
if exist_recommend == 1:
return _db_data1
elif exist_recommend == 0:
return _db_data2
def memberx3d5(self):
'''
invitation < 3, recommend > 5
'''
try:
_db_data = self.db.query('select customer_id from bussiness_member_recommend where \
customer_id in (select customer_id from positioninv group by customer_id \
having count(*) < 3) group by customer_id having count(*) >= 5;')
#print _db_data
for x in _db_data:
print self.db.query('select * from bussiness_member_recommend where customer_id = ' + str(x['customer_id']))
print '\n'
except Exception, e:
print traceback.print_exc()
return
return _db_data
def memberx3x5(self):
try:
_db_data = self.db.query('select customer_id from bussiness_member_recommend where \
customer_id in (select customer_id from positioninv group by customer_id \
having count(*) < 3) group by customer_id having count(*) <5;')
except Exception, e:
print traceback.print_exc()
return
return _db_data
def nofeedbackintime(self):
try :
_db_data = self.db.query('select customer_id \
from positioninv group by customer_id having ')
except Exception, e:
print traceback.print_exc()
return
return _db_data
def b_extremity_no_feedback(self):
try:
_db_data = self.db.query('select bussiness_id \
from bussiness_member_recommend \
where status = 1 group by bussiness_id \
having count(*) > 30 order by bussiness_id')
except Exception, e:
print traceback.print_exc()
return
return _db_data
def b_extremity_no_feedback_del_recommend(self):
'''
7天未处理 删除推荐
'''
try:
_db_data = self.db.query('select * from \
bussiness_member_recommend where status = 1 \
and UNIX_TIMESTAMP() - created_at > 604800;')
_db_data1 = self.db.query('select * from positioninv \
where status = 2 and UNIX_TIMESTAMP() - completed_at \
> 604800; ')
except Exception, e:
print traceback.print_exc()
return
return _db_data
def b_extremity_no_feedback_stop_recommend(self):
'''
三天没有操作,停止推荐,并且通知
'''
try:
_db_data = self.db.query('select * from \
bussiness_member_recommend where status = 1 \
and UNIX_TIMESTAMP() - created_at > 259200;')
_db_data = self.db.query('select * from positioninv \
where status = 2 and \
UNIX_TIMESTAMP() - completed_at > 259200;')
except Exception, e:
print traceback.print_exc()
return
return _db_data
def c_extremity_no_feedback(self):
'''
sieve (id, time, )
'''
try :
#
#_db_data = self.db.query('select inv_id, customer_id, \
#completed_at, status from positioninv where status = 0')
_db_data1 = self.db.query('select inv_id, customer_id \
from positioninv where status = 0 and UNIX_TIMESTAMP() \
- completed_at > 172800 ')
except Exception, e:
print traceback.print_exc()
return
return _db_data1
def c_extremity_no_feedback_close_recommend(self):
'''
72小时无法处理将这个邀请置为过期,关闭此人推荐
'''
try :
_db_data - self.db.query('select inv_id,customer_id,from positioninv \
where status = 0 and UNIX_TIMESTAMP() - completed_at > 259200')
except Exception, e:
print traceback.print_exc()
return
return _db_data
def test_1():
db = Db()
member1 = db.memberx3d5()
for x in member1:
member2 = dm.memberx3x5()
def test_danger():
db = Db()
member0 = db.membersmall5(0)
member1 = db.membersmall5(1)
for y in member0:
sendemail.get_params(emailto = str(x['email'])),
emailfrom = 'datacenter@sendcloud.org',
fromname = 'DataCenter',
subject = '请修改条件,修改职位描述'
content = x['name']+'你好: 你的职位推荐有问题,请修改'
for x in member1:
sendemail.get_params(emailto = str(x['email'])),
emailfrom = 'datacenter@sendcloud.org',
fromname = 'DataCenter',
subject = '请修改条件,修改职位描述'
content = x['name']+'你好: 你的职位推荐有问题,请修改'
member2 = db.memberx3d5()
# sendemail.get_params(emailto = str())
def test():
db = Db()
#db.memberx3d5()
mem0 = db.membersmall5(0)
mem1 = db.membersmall5(1)
for x in mem0:
_name = x['name'].encode('utf-8')
_email = x['email'].encode('utf-8')
_tel = x['telephone'].encode('utf-8')
def task():
db = Db()
member1 = db.membersmall5()
#continue recommend member1
#continue_recommend(member1)
continue_member1 = db.membersmall5()
for n1_member in continue_member1:
print n1_member
'''
# notify module
'''
#notify
member2 = db.memberx3d5()
for n2_member in member2:
print n2_member
'''
# 无法解决
'''
member3 = db.memberx3x5()
#continue_recommend(member3)
member4 = db.c_extremity_no_feedback()
member5 = db.b_extremity_no_feedback()
#notify b-member
#_now_time2 = time.time()
if __name__ == '__main__':
# db = mysqldb.Connection(host,dbname,dbuser,password)
# test()
# task start
test()