]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blob - html/qa.php
Add filter-out feature to rpmqa query page (adamg?)
[projects/pld-ftp-admin.git] / html / qa.php
1 <!doctype html>
2 <html lang='en'>
3 <head>
4 <link rel="Shortcut Icon" href="//www.pld-linux.org/favicon.ico"/>
5         <title>PLD QA Reports</title>
6         <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="//srcbuilder.pld-linux.org/th/style.css">
7         <style>
8                 .hidden { display: none; }
9                 span#count { font-weight: bold; }
10         </style>
11 </head>
12 <body>
13 <?php
14
15 // (c) -2019 PLD developers
16 // filter-out feature - adamg
17
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
28         "main-x32" => "Main deps x32",
29         "main-ready-x32" => "Main ready deps x32",
30         "main-ready-test-x32" => "Main+ready+test deps x32",
31
32         "freshness" => "GIT vs FTP freshness",
33
34         "lint-PLD" => "rpmlint: main",
35         "lint-test" => "rpmlint: test",
36         "lint-ready" => "rpmlint: ready",
37 );
38
39 function reports_selection($reports) {
40         global $report;
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";
47 }
48
49 /**
50  * Create text input for filtering results
51  */
52 function filter_box() {
53         echo '<br>Filter results: <input id="filter" class="filter">';
54         echo '<br>Filter-out (grep -v) <input id="filter_out" class="filter">';
55         echo '<br><span id="count">?</span> errors';
56 }
57
58 function format_report($report) {
59         echo "<br>View the <a href=$report.txt>raw</a> report<br/>\n";
60         $file = "$report.txt";
61         $giturl = 'http://git.pld-linux.org/gitweb.cgi?p=packages/%1$s.git;f=%1$s.spec;h=HEAD;a=shortlog';
62         echo '<ol id="lines">';
63         foreach (file($file) as $line) {
64                 $line = preg_replace_callback('/^(?P<prefix>error:|GIT:)\s*\[(?P<spec>[^]]+)\]\s*(?P<msg>.+)$/', function($m) use ($giturl) {
65                         $package = basename($m['spec'], '.spec');
66                         $url = sprintf($giturl, $package);
67                         return sprintf('<li><font color=red>%s</font> [<a href="%s">%s</a>] %s', $m['prefix'], $url, $m['spec'], $m['msg']);
68                 }, $line);
69                 echo $line, "<br/>\n";
70         }
71         echo '</ol>';
72 }
73
74 reports_selection($reports);
75 filter_box();
76 if (isset($reports[$report])) {
77         format_report($report);
78 }
79
80 ?>
81 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
82 <script>
83 jQuery(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>
116 </body>
117 </html>
This page took 0.054314 seconds and 3 git commands to generate.