示例#1
0
    def get(self, begin_time, end_time):
        result = pd.DataFrame(columns=["name", "days"])
        leaves = pd.read_json(
            json.dumps(Leave.between(begin_time, end_time,query_type=False)))

        if leaves.empty:
            return self.succ([])

        for name, g in leaves.groupby("uid"):
            result.set_value(len(result), ["name", "days"], [name, g.days.sum()])

        result_lst = []
        result.sort_values("days", ascending=False).apply(
            lambda x: result_lst.append({"name": x["name"], "days": x["days"]}), axis=1)

        return self.succ(result_lst)
示例#2
0
    def get(self, begin_time, end_time):
        result = pd.DataFrame(columns=["name", "days"])
        leaves = pd.read_json(
            json.dumps(Leave.between(begin_time, end_time, query_type=False)))

        if leaves.empty:
            return self.succ([])

        for name, g in leaves.groupby("uid"):
            result.set_value(len(result), ["name", "days"],
                             [name, g.days.sum()])

        result_lst = []
        result.sort_values("days", ascending=False).apply(
            lambda x: result_lst.append({
                "name": x["name"],
                "days": x["days"]
            }),
            axis=1)

        return self.succ(result_lst)
示例#3
0
    route = ["/stats/leave/days/<string:begin_time>/<string:end_time>"]

    def get(self, begin_time, end_time):
        result = pd.DataFrame(columns=["name", "days"])
        leaves = pd.read_json(
            json.dumps(Leave.between(begin_time, end_time,query_type=False)))

        if leaves.empty:
            return self.succ([])

        for name, g in leaves.groupby("uid"):
            result.set_value(len(result), ["name", "days"], [name, g.days.sum()])

        result_lst = []
        result.sort_values("days", ascending=False).apply(
            lambda x: result_lst.append({"name": x["name"], "days": x["days"]}), axis=1)

        return self.succ(result_lst)


if __name__ == "__main__":
    result = pd.DataFrame(columns=["name", "days"])

    leaves = pd.read_json(
        json.dumps(Leave.between("2016-01-01", "2016-03-07")))

    for name, g in leaves.groupby("uid"):
        result.set_value(len(result), ["name", "days"], [name, g.days.sum()])

    print(result)
示例#4
0
            json.dumps(Leave.between(begin_time, end_time, query_type=False)))

        if leaves.empty:
            return self.succ([])

        for name, g in leaves.groupby("uid"):
            result.set_value(len(result), ["name", "days"],
                             [name, g.days.sum()])

        result_lst = []
        result.sort_values("days", ascending=False).apply(
            lambda x: result_lst.append({
                "name": x["name"],
                "days": x["days"]
            }),
            axis=1)

        return self.succ(result_lst)


if __name__ == "__main__":
    result = pd.DataFrame(columns=["name", "days"])

    leaves = pd.read_json(json.dumps(Leave.between("2016-01-01",
                                                   "2016-03-07")))

    for name, g in leaves.groupby("uid"):
        result.set_value(len(result), ["name", "days"], [name, g.days.sum()])

    print(result)
示例#5
0
文件: leave.py 项目: cash2one/bmp
    def get(self, begin_time, end_time):
        query = Leave.between(begin_time, end_time).filter(Leave.days > 0)

        return self.succ([Leave._to_dict(l) for l in query.all()])