temp article for superset

  • 采用hostname + ip -> hash–> testcase_hash 表名;
  • 每个用户的每个测试用例 都有一张唯一的表;
  • 测试用例的数据存储到服务器的db中,后面的测试会覆盖之前的数据;
  • 高级数据分析时,每个用户仅看到自己的数据;
  • 前端请求数据时,js获取hostname + ip hash加密,放入请求头;
  • 后端根据请求头中的hash值,对所有tables过滤,拿到当前用户的所有表;
  • QWebEngine 将当前的测试用例名称,传给js,js放入请求头,实现过滤当前测试用例的表。
@app.after_request
    def analyze_response(res):
        if request.path.startswith("/api/v1/dataset"):
            logging.info(f"res headers: {
      
      res.headers}")
            attr = [i for i in dir(res) if not i.startswith("_")]
            logging.info(f"res data:{
      
      attr}")

            # logging.info(f"res data:{res.json}")
            data = res.response[0]
            logging.info(f"response:{
      
      data}")
            logging.info(f"content encoding: {
      
      res.content_encoding}")

            import brotli
            import json
            result = brotli.decompress(data).decode("utf-8")
            res_json = json.loads(result)
            logging.info(f"brotli:{
      
      res_json}")
            temp = res_json.get("result")
            # 过滤后的数据
            filter_tables = [i for i in temp if "222" in i["table_name"]]
            # short tablename
            for i in filter_tables:
                i["table_name"] = i.get("table_name").replace("fing", "")
            res_json["result"] = filter_tables
            # 转json字节串
            json_bytes = json.dumps(res_json).encode("utf-8")
            res_data = brotli.compress(json_bytes)
            # br压缩的数据 放入响应
            # res.response[0] = res_data
            res.set_data(res_data)

        return res

js 获取hostname
https://www.cnblogs.com/lianfeng/p/7089336.html
md5
https://blog.csdn.net/qq_52522995/article/details/123329242

猜你喜欢

转载自blog.csdn.net/weixin_45228198/article/details/131447165