]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - html/qa.php
Add filter-out feature to rpmqa query page (adamg?)
[projects/pld-ftp-admin.git] / html / qa.php
CommitLineData
11c36e0f
JR
1<!doctype html>
2<html lang='en'>
ef63dafd 3<head>
2ff4e4d5 4<link rel="Shortcut Icon" href="//www.pld-linux.org/favicon.ico"/>
ef63dafd 5 <title>PLD QA Reports</title>
2ff4e4d5 6 <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="//srcbuilder.pld-linux.org/th/style.css">
95dbdd8c 7 <style>
11c36e0f
JR
8 .hidden { display: none; }
9 span#count { font-weight: bold; }
95dbdd8c 10 </style>
ef63dafd 11</head>
ef63dafd
ER
12<body>
13<?php
14
11c36e0f
JR
15// (c) -2019 PLD developers
16// filter-out feature - adamg
17
ef63dafd
ER
18$report = isset($_GET['q']) ? basename($_GET['q']) : null;
19$reports = array(
20 "main" => "Main deps x86_64",
21 "main-ready" => "Main ready deps x86_64",
22 "main-ready-test" => "Main+ready+test deps x86_64",
23
24 "main-i686" => "Main deps i686",
25 "main-ready-i686" => "Main ready deps i686",
26 "main-ready-test-i686" => "Main+ready+test deps i686",
27
34957462
ER
28 "main-x32" => "Main deps x32",
29 "main-ready-x32" => "Main ready deps x32",
30 "main-ready-test-x32" => "Main+ready+test deps x32",
38f51586
ER
31
32 "freshness" => "GIT vs FTP freshness",
33
34 "lint-PLD" => "rpmlint: main",
35 "lint-test" => "rpmlint: test",
36 "lint-ready" => "rpmlint: ready",
ef63dafd
ER
37);
38
8e5b91b1 39function reports_selection($reports) {
bf022007 40 global $report;
8e5b91b1
ER
41 echo "Select report:";
42 echo "<select id=q name=q>\n";
43 foreach ($reports as $q => $title) {
44 printf("<option value=%s %s>%s</option>\n", $q, $q == $report ? 'selected' :'', $title);
45 }
46 echo "</select>\n";
ef63dafd 47}
ef63dafd 48
95dbdd8c
ER
49/**
50 * Create text input for filtering results
51 */
52function filter_box() {
11c36e0f
JR
53 echo '<br>Filter results: <input id="filter" class="filter">';
54 echo '<br>Filter-out (grep -v) <input id="filter_out" class="filter">';
95dbdd8c
ER
55 echo '<br><span id="count">?</span> errors';
56}
57
8e5b91b1 58function format_report($report) {
95dbdd8c 59 echo "<br>View the <a href=$report.txt>raw</a> report<br/>\n";
ef63dafd 60 $file = "$report.txt";
99eefd6f 61 $giturl = 'http://git.pld-linux.org/gitweb.cgi?p=packages/%1$s.git;f=%1$s.spec;h=HEAD;a=shortlog';
95dbdd8c 62 echo '<ol id="lines">';
99eefd6f 63 foreach (file($file) as $line) {
38f51586 64 $line = preg_replace_callback('/^(?P<prefix>error:|GIT:)\s*\[(?P<spec>[^]]+)\]\s*(?P<msg>.+)$/', function($m) use ($giturl) {
99eefd6f
ER
65 $package = basename($m['spec'], '.spec');
66 $url = sprintf($giturl, $package);
3e190aa2 67 return sprintf('<li><font color=red>%s</font> [<a href="%s">%s</a>] %s', $m['prefix'], $url, $m['spec'], $m['msg']);
99eefd6f
ER
68 }, $line);
69 echo $line, "<br/>\n";
70 }
3e190aa2 71 echo '</ol>';
ef63dafd
ER
72}
73
8e5b91b1 74reports_selection($reports);
95dbdd8c 75filter_box();
8e5b91b1
ER
76if (isset($reports[$report])) {
77 format_report($report);
78}
79
ef63dafd 80?>
11c36e0f
JR
81<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
82<script>
83jQuery(function($) {
84 $('#q').on('change', function(e) {
85 var el = e.target;
86 var o = el.options;
87 var v = o[o.selectedIndex].value;
88 location.href = "?q=" + v;
89 });
90
91 var $lines = $('#lines>li');
92 var $count = $('#count');
93 $('.filter').on('keyup', function() {
94 var filter_in = $('#filter').val();
95 var filter_out = $('#filter_out').val().trim();
96 var do_filter_out = filter_out.length > 0;
97 var count = 0;
98 $lines.each(function() {
99 var $line = $(this);
100 var text = $line.text();
101 // everything is visible by default
102 $line.removeClass('hidden');
103 count++;
104 // but we hide lines that do not match filter
105 // OR match non-empty filter-out
106 if ( ! text.match(filter_in) || (do_filter_out && text.match(filter_out)) ) {
107 $line.addClass('hidden');
108 count--;
109 }
110 });
111 $count.html(count);
112 });
113 $count.html($lines.length);
114});
115</script>
ef63dafd
ER
116</body>
117</html>
This page took 2.971474 seconds and 4 git commands to generate.