Exemple #1
0
def detect_daily_record_count(msg, msg_dict):
	if not (msg_dict['MsgType'] == 'text' and msg_dict.has_key('MsgId')):
		return True
	username = ""
	service_name = msg_dict['ToUserName']
	index_key = "%s_record_count" % (util.seconds_to_date(msg_dict['CreateTime']))
	index_value = util.get_serviceprofile(service_name, index_key, 0)

	index_value = int(index_value) + 1
	util.update_serviceprofile(service_name, index_key, index_value)
Exemple #2
0
def detect_daily_record_count(msg, msg_dict):
    if not (msg_dict["MsgType"] == "text" and msg_dict.has_key("MsgId")):
        return True
    username = ""
    service_name = msg_dict["ToUserName"]
    index_key = "%s_record_count" % (util.seconds_to_date(msg_dict["CreateTime"]))
    index_value = util.get_serviceprofile(service_name, index_key, 0)

    index_value = int(index_value) + 1
    util.update_serviceprofile(service_name, index_key, index_value)
Exemple #3
0
def detect_daily_unsubscribe_count(msg, msg_dict):
	if not (msg_dict['MsgType'] == 'event' and msg_dict['Event'] == 'unsubscribe'):
		return True

	username = ""
	service_name = msg_dict['ToUserName']
	index_key = "%s_unsubscribe_count" % (util.seconds_to_date(msg_dict['CreateTime']))
	index_value = util.get_serviceprofile(service_name, index_key, 0)

	index_value = int(index_value) + 1
	util.update_serviceprofile(service_name, index_key, index_value)
Exemple #4
0
def detect_daily_unsubscribe_count(msg, msg_dict):
    if not (msg_dict["MsgType"] == "event" and msg_dict["Event"] == "unsubscribe"):
        return True

    username = ""
    service_name = msg_dict["ToUserName"]
    index_key = "%s_unsubscribe_count" % (util.seconds_to_date(msg_dict["CreateTime"]))
    index_value = util.get_serviceprofile(service_name, index_key, 0)

    index_value = int(index_value) + 1
    util.update_serviceprofile(service_name, index_key, index_value)
Exemple #5
0
def detect_user_count(msg, msg_dict):
	if not (msg_dict['MsgType'] == 'event'):
		return True

	username = ""
	service_name = msg_dict['ToUserName']
	index_key = "user_count"
	index_value = util.get_serviceprofile(service_name, index_key, 0)

	if (msg_dict['Event'] == "subscribe"):
		index_value = int(index_value) + 1
	if (msg_dict['Event'] == "unsubscribe"):
		index_value = int(index_value) - 1

	util.update_serviceprofile(service_name, index_key, index_value)
Exemple #6
0
def detect_user_count(msg, msg_dict):
    if not (msg_dict["MsgType"] == "event"):
        return True

    username = ""
    service_name = msg_dict["ToUserName"]
    index_key = "user_count"
    index_value = util.get_serviceprofile(service_name, index_key, 0)

    if msg_dict["Event"] == "subscribe":
        index_value = int(index_value) + 1
    if msg_dict["Event"] == "unsubscribe":
        index_value = int(index_value) - 1

    util.update_serviceprofile(service_name, index_key, index_value)
Exemple #7
0
def detect_daily_valid_record_count(msg, msg_dict):
	if not (msg_dict['MsgType'] == 'text' and msg_dict.has_key('MsgId') is False):
		return True

	content = msg_dict['Content']
	if content.find("记好了") == -1:
		return True

	print "======= here ===="
	username = ""
	service_name = msg_dict['FromUserName']
	index_key = "%s_valid_record_count" % (util.seconds_to_date(msg_dict['CreateTime']))
	index_value = util.get_serviceprofile(service_name, index_key, 0)

	index_value = int(index_value) + 1
	util.update_serviceprofile(service_name, index_key, index_value)
Exemple #8
0
def detect_daily_valid_record_count(msg, msg_dict):
    if not (msg_dict["MsgType"] == "text" and msg_dict.has_key("MsgId") is False):
        return True

    content = msg_dict["Content"]
    if content.find("记好了") == -1:
        return True

    print "======= here ===="
    username = ""
    service_name = msg_dict["FromUserName"]
    index_key = "%s_valid_record_count" % (util.seconds_to_date(msg_dict["CreateTime"]))
    index_value = util.get_serviceprofile(service_name, index_key, 0)

    index_value = int(index_value) + 1
    util.update_serviceprofile(service_name, index_key, index_value)
Exemple #9
0
def detect_daily_uniq_user_count(msg, msg_dict):
	if not (msg_dict['MsgType'] == 'text' and msg_dict.has_key('MsgId')):
		return True

	conn = MySQLdb.connect(config.DB_HOST, config.DB_USERNAME, \
		config.DB_PWD, config.DB_NAME, charset = 'utf8mb4', port = config.DB_PORT)

	date = util.seconds_to_date(msg_dict['CreateTime'])
	username = ''
	service_name = msg_dict['ToUserName']
	index_key = "%s_uniq_user_count" % (date)

	# TODO: need to improve performance, instead of query the whole dataset
	sql_format = "select count(1) from userprofile " + \
				 "where index_key = '%s_visit_count' and service_name = '%s';"
	sql = sql_format % (date, service_name)
	out = util.query_sql(conn, sql)

	if len(out) == 0:
		index_value = 0
	else:
		index_value = out[0][0] + 0

	util.update_serviceprofile(service_name, index_key, index_value)
Exemple #10
0
def detect_daily_uniq_user_count(msg, msg_dict):
    if not (msg_dict["MsgType"] == "text" and msg_dict.has_key("MsgId")):
        return True

    conn = MySQLdb.connect(
        config.DB_HOST, config.DB_USERNAME, config.DB_PWD, config.DB_NAME, charset="utf8mb4", port=config.DB_PORT
    )

    date = util.seconds_to_date(msg_dict["CreateTime"])
    username = ""
    service_name = msg_dict["ToUserName"]
    index_key = "%s_uniq_user_count" % (date)

    # TODO: need to improve performance, instead of query the whole dataset
    sql_format = "select count(1) from userprofile " + "where index_key = '%s_visit_count' and service_name = '%s';"
    sql = sql_format % (date, service_name)
    out = util.query_sql(conn, sql)

    if len(out) == 0:
        index_value = 0
    else:
        index_value = out[0][0] + 0

    util.update_serviceprofile(service_name, index_key, index_value)