Ejemplo n.º 1
0
    def total_chart(self):
        records = []
        for i in range(-6, 1, 1):
            records.append(self.__get_total_score(i))

        date = [-6, -5, -4, -3, -2, -1, 0]
        x_ticks = ArrowUtil.format_weekly_date()

        legend = self.column_list
        data = []
        for l in legend:
            data.append(list(map(lambda x: x[l], records)))

        f_name = "total_weekly_report.png"
        title = "Total Report"

        Plot.make_line(
            date,
            data,
            f_name,
            legend=legend,
            x_ticks=x_ticks,
            x_label="Total Point",
            y_label="Days",
            title=title,
        )
        self.slackbot.file_upload(f_name, title=title, comment=MsgResource.TOTAL_REPORT)
Ejemplo n.º 2
0
    def total_chart(self):
        records = []
        for i in range(-6, 1, 1):
            records.append(self.__get_total_score(i))

        date = [-6, -5, -4, -3, -2, -1, 0]
        x_ticks = ArrowUtil.format_weekly_date()

        legend = self.column_list
        data = []
        for l in legend:
            data.append(list(map(lambda x: x[l], records)))

        f_name = "total_weekly_report.png"
        title = "Total Report"

        Plot.make_line(
            date,
            data,
            f_name,
            legend=legend,
            x_ticks=x_ticks,
            x_label="Total Point",
            y_label="Days",
            title=title,
        )
        self.slackbot.file_upload(f_name,
                                  title=title,
                                  comment=MsgResource.TOTAL_REPORT)
Ejemplo n.º 3
0
    def commit(self, timely="daily"):
        events = self.github.get_user(self.username).get_events()

        if isinstance(timely, int):
            point_start = self.__time_point(timely)
            point_end = self.__time_point(timely + 1)

            commit_count = self.__get_event_count(events, point_start,
                                                  point_end)
            return commit_count

        elif timely == "daily":
            point_start = self.__time_point(0)
            point_end = self.__time_point(1)

            commit_count = self.__get_event_count(events, point_start,
                                                  point_end)
            if commit_count == 0:
                self.slackbot.send_message(
                    text=MsgResource.GITHUB_COMMIT_EMPTY)
            else:
                self.slackbot.send_message(
                    text=MsgResource.GITHUB_COMMIT_EXIST(
                        commit_count=commit_count))

        elif timely == "weekly":
            commit_count_list = []
            for i in range(-6, 1, 1):
                record = self.data_handler.read_record(days=i)
                commit_count_list.append(record.get("Github", 0))

            date = [-6, -5, -4, -3, -2, -1, 0]
            x_ticks = ArrowUtil.format_weekly_date()
            y_ticks = [i for i in range(max(commit_count_list) + 1)]

            f_name = "github_weekly_commit.png"
            title = "Github Commit"

            Plot.make_bar(
                date,
                commit_count_list,
                f_name,
                x_ticks=x_ticks,
                y_ticks=y_ticks,
                x_label="Commit Count",
                title=title,
            )
            self.slackbot.file_upload(f_name,
                                      title=title,
                                      comment=MsgResource.GITHUB_COMMIT_WEEKLY)

        elif timely == "ten_days":
            commit_count_list = []
            for i in range(-9, 1, 1):
                point_start = self.__time_point(i)
                point_end = self.__time_point(i + 1)
                commit_count_list.append(
                    self.__get_event_count(events, point_start, point_end))
            return commit_count_list
Ejemplo n.º 4
0
    def commit(self, timely="daily"):
        events = self.github.get_user(self.username).get_events()

        if isinstance(timely, int):
            point_start = self.__time_point(timely)
            point_end = self.__time_point(timely + 1)

            commit_count = self.__get_event_count(events, point_start, point_end)
            return commit_count

        elif timely == "daily":
            point_start = self.__time_point(0)
            point_end = self.__time_point(1)

            commit_count = self.__get_event_count(events, point_start, point_end)
            if commit_count == 0:
                self.slackbot.send_message(text=MsgResource.GITHUB_COMMIT_EMPTY)
            else:
                self.slackbot.send_message(
                    text=MsgResource.GITHUB_COMMIT_EXIST(commit_count=commit_count)
                )

        elif timely == "weekly":
            commit_count_list = []
            for i in range(-6, 1, 1):
                record = self.data_handler.read_record(days=i)
                commit_count_list.append(record.get("Github", 0))

            date = [-6, -5, -4, -3, -2, -1, 0]
            x_ticks = ArrowUtil.format_weekly_date()
            y_ticks = [i for i in range(max(commit_count_list) + 1)]

            f_name = "github_weekly_commit.png"
            title = "Github Commit"

            Plot.make_bar(
                date,
                commit_count_list,
                f_name,
                x_ticks=x_ticks,
                y_ticks=y_ticks,
                x_label="Commit Count",
                title=title,
            )
            self.slackbot.file_upload(
                f_name, title=title, comment=MsgResource.GITHUB_COMMIT_WEEKLY
            )

        elif timely == "ten_days":
            commit_count_list = []
            for i in range(-9, 1, 1):
                point_start = self.__time_point(i)
                point_end = self.__time_point(i + 1)
                commit_count_list.append(
                    self.__get_event_count(events, point_start, point_end)
                )
            return commit_count_list