Ejemplo n.º 1
0
 def expire_at_this_end_of_month(self, key):
     # 本月月底过期
     from tools_lib.common_util.archived.gtz import TimeZone
     local_now = TimeZone.local_now()
     end_of_this_month = TimeZone.utc_to_local(
         TimeZone.month_range(local_now.year, local_now.month)[1])
     self.expireat(key, end_of_this_month)
     self.delete()
Ejemplo n.º 2
0
    def get(self):
        """
            @api {get} /express/yun/op_data 风云 - 运营数据
            @apiName yun_op_data
            @apiGroup app_fe
            @apiVersion 0.0.1

            @apiParam (query param) {string} date 一个月中的某一天

            @apiSuccessExample 成功返回示例
            HTTP/1.1 200 OK
            [
                {
                "hr_break": 0,
                "zj_pay": 0,
                "create_time": "2016-05-19T17:00:00Z",
                "cl_shift": 0,
                "dd_error_count": 1,
                "sh_valid": 0,
                "hr_invite": 0,
                "sh_register": 0,
                "sh_order": 0,
                "zj_cash_back": 0,
                "dd_count": 0,
                "hr_interview": 0,
                "zj_top_up": 0,
                "sh_complain": 0,
                "hr_consulting": 0,
                "hr_entry": 0,
                "hr_active": 0,
                "dd_tt_count": 0,
                "hr_leave": 0,
                "cl_late": 0,
                "dd_sj_count": 0,
                "hr_on_job": 2,
                "cl_depart": 0,
                "sh_visit": 0
                },
                ...
            ]
            @apiUse bad_response
        """
        try:
            data = Schema({
                "date": schema_date
            }).validate(self.get_query_args())
        except:
            self.resp_args_error()
            return

        start, end = TimeZone.month_range(value=data['date'])

        query = {
            "create_time__gte": start,
            "create_time__lte": end,
            "excludes": ["id"]
        }

        resp = yield self.async_fetch(bl_data.redirect_op_data_search(query))

        content = resp.content

        total = dict()
        for _ in content:
            for (k, v) in list(_.items()):
                if k in total:
                    total[k] += v
                else:
                    total[k] = v

        total['create_time'] = "总计"
        content.insert(0, total)
        self.resp(content=content)