def get_user_latest_inputtext(): service_name = request.args.get('service_name') url = "http://%s:%d/get_user_latest_inputtext?service_name=%s" % \ (config.GATEWAY_HOST, config.GATEWAY_PORT, service_name) print "%s\n" % url data = util.request_http_json(url) content = "" for entry in data: username = entry["username"] facename = util.username_to_facename(username, service_name) if facename == config.EMPTY_FACENAME: facename = "[%s]" % username else: facename = "[%s] [%s]" % (facename, username) content ="%s[%s] %s %s<br/>" \ % (content, \ datetime.datetime.fromtimestamp(int(entry["createtime"])).strftime('%H:%M:%S'), \ facename, entry["content"]) content = "<font size=4>%s</font>" % (content) resp = make_response(content, 200) resp.headers['Content-type'] = 'text/html; charset=utf-8' return resp
def get_index_daily_users_lines(): username_list = request.args.get('username_list').split(";") service_name = request.args.get('service_name') index_key_list = request.args.get('index_key_list', '') if index_key_list == "": index_name = request.args.get('index_name') days = util.latest_days(10) l = map(lambda x: "%s_%s" % (x, index_name) , days) index_key_list = ";".join(l) lineName_list = [] value_lists = [] for username in username_list: url = "http://%s:%d/get_index_userprofile?username=%s&service_name=%s&index_key_list=%s" % \ (config.GATEWAY_HOST, config.GATEWAY_PORT, username, service_name, index_key_list) print "%s\n" % url data = util.request_http_json(url) (name, key_list, value_list) = util.parse_daily_index(data) key_list = map(lambda x: "'%s-%s'" % (x[4:6], x[6:8]), key_list) value_lists.append(",".join(value_list)) facename= util.username_to_facename(username, service_name) if facename != config.EMPTY_FACENAME: lineName_list.append(facename) else: lineName_list.append(username) title=u"若干用户每日指标统计 -- %s" % (name) # facename= util.username_to_facename(username, service_name) # if facename != config.EMPTY_FACENAME: # subtitle = "facename:%s" % (facename) # else: # subtitle = "username:%s" % (username) subtitle = "" xTitle = u"日期/MMDD" yTitle = u"数量/个" content = render_template('get_index_lines.html', \ title = title, subtitle = subtitle,\ xTitle = xTitle, yTitle = yTitle, \ lineName_list = lineName_list, \ key_list = ",".join(key_list), \ line_count = len(lineName_list),\ value_lists = value_lists, \ objs=None) resp = make_response(content, 200) resp.headers['Content-type'] = 'text/html; charset=utf-8' return resp