示例#1
0
    def components(self, cmdline, db, opsys, release):
        """
        Get statistics for most crashing components
        """

        hist_table, hist_field = get_history_target(self.history_type)
        total = get_history_sum(db, opsys, release)
        comps = get_report_count_by_component(db, opsys, release)

        if cmdline.last:
            now = datetime.datetime.now()
            since = now - datetime.timedelta(days=int(cmdline.last))
            comps = comps.filter(hist_field >= since)
            total = total.filter(hist_field >= since)

        total_num = total.first()[0]

        limit = int(cmdline.count)
        limit_details = int(cmdline.detail_count)
        results = []

        for num, (comp, count) in enumerate(comps):
            if num >= limit:
                break

            if comp in self.comps_filter:
                continue

            reports = get_report_stats_by_component(db, comp, opsys, release,
                                                    self.history_type)

            if cmdline.last:
                reports = reports.filter(hist_field >= since)

            problem_ids = set()
            attached_reports = []

            for report, report_count in reports:
                if len(problem_ids) >= limit_details:
                    break
                if not report.problem:
                    continue
                if report.problem.id in problem_ids:
                    continue
                if report.quality < 0 and not cmdline.include_low_quality:
                    continue

                problem_ids.add(report.problem.id)

                problem_url = ""
                if webfaf_installed():
                    problem_url = reverse("problems.item",
                                          problem_id=report.problem.id)

                attached_reports.append((problem_url, report.bugs))

            results.append((comp, count, attached_reports))

        if not results:
            return ""

        out = "Components:\n\n"

        for num, (comp, count, reports) in enumerate(results):
            if reports:
                out += ("{0}. {1} seen {2} times ({3:.0%} of all reports)\n".
                        format(num + 1, comp, count, count / float(total_num)))

                for problem_url, bugs in reports:
                    if problem_url or bugs:
                        out += "    {0} {1}\n".format(
                            problem_url, ", ".join(map(str, bugs)))

        return out
示例#2
0
文件: stats.py 项目: mjtrangoni/faf
    def components(self, cmdline, db, opsys, release):
        """
        Get statistics for most crashing components
        """

        hist_table, hist_field = get_history_target(self.history_type)
        total = get_history_sum(db, opsys, release)
        comps = get_report_count_by_component(db, opsys, release)

        if cmdline.last:
            now = datetime.datetime.now()
            since = now - datetime.timedelta(days=int(cmdline.last))
            comps = comps.filter(hist_field >= since)
            total = total.filter(hist_field >= since)

        total_num = total.first()[0]

        limit = int(cmdline.count)
        limit_details = int(cmdline.detail_count)
        results = []

        for num, (comp, count) in enumerate(comps):
            if num >= limit:
                break

            if comp in self.comps_filter:
                continue

            reports = get_report_stats_by_component(db, comp, opsys,
                                                    release,
                                                    self.history_type)

            if cmdline.last:
                reports = reports.filter(hist_field >= since)

            problem_ids = set()
            attached_reports = []

            for report, report_count in reports:
                if len(problem_ids) >= limit_details:
                    break
                if not report.problem:
                    continue
                if report.problem.id in problem_ids:
                    continue
                if report.quality < 0 and not cmdline.include_low_quality:
                    continue

                problem_ids.add(report.problem.id)

                problem_url = ""
                if webfaf_installed():
                    problem_url = reverse("problems.item",
                                          problem_id=report.problem.id)

                attached_reports.append((problem_url, report.bugs))

            results.append((comp, count, attached_reports))

        if not results:
            return ""

        out = "Components:\n\n"

        for num, (comp, count, reports) in enumerate(results):
            if reports:
                out += ("{0}. {1} seen {2} times ({3:.0%} of all reports)\n"
                        .format(num + 1, comp, count, count / float(total_num)))

                for problem_url, bugs in reports:
                    if problem_url or bugs:
                        out += "    {0} {1}\n".format(
                            problem_url, ", ".join(map(str, bugs)))

        return out