Remove passing result urls (#3175)
This commit is contained in:
parent
9c3afa5fdb
commit
6000536aa2
|
|
@ -973,6 +973,14 @@ module.exports.parseCommandLine = function parseCommandLine() {
|
|||
describe: 'The output format of the budget.',
|
||||
group: 'Budget'
|
||||
})
|
||||
.option('budget.removeWorkingResult', {
|
||||
alias: 'budget.removePassingResult',
|
||||
type: 'boolean',
|
||||
describe:
|
||||
'Remove the result of URLs that pass the budget. You can use this if you many URL and only care about the ones that fails your budget. All videos/HTML for the working URLs will be removed if you pass this on.',
|
||||
group: 'Budget'
|
||||
})
|
||||
|
||||
/** Screenshot */
|
||||
.option('browsertime.screenshot', {
|
||||
type: 'boolean',
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ const log = require('intel').getLogger('sitespeedio.plugin.budget');
|
|||
module.exports = {
|
||||
open(context, options) {
|
||||
this.options = options;
|
||||
this.budgetOptions = options.budget || {};
|
||||
this.storageManager = context.storageManager;
|
||||
this.result = context.budget;
|
||||
this.make = context.messageMaker('budget').make;
|
||||
|
|
@ -67,6 +68,12 @@ module.exports = {
|
|||
|
||||
queue.postMessage(this.make('budget.result', this.result));
|
||||
|
||||
if (this.budgetOptions.removeWorking) {
|
||||
for (const url of Object.keys(this.result.working)) {
|
||||
queue.postMessage(this.make('remove.url', {}, { url }));
|
||||
}
|
||||
}
|
||||
|
||||
for (const url of Object.keys(this.result.working)) {
|
||||
working = working + this.result.working[url].length;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ class DataCollector {
|
|||
delete this.urlPages[url];
|
||||
}
|
||||
|
||||
getRemovedURLs() {
|
||||
return Object.keys(this.removedUrls);
|
||||
}
|
||||
|
||||
getSummary(name) {
|
||||
return this.summaryPages[name];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,7 +374,10 @@ class HTMLBuilder {
|
|||
merge(
|
||||
{
|
||||
options,
|
||||
noPages: dataCollector.getURLs().length,
|
||||
noPages:
|
||||
dataCollector.getURLs().length +
|
||||
dataCollector.getRemovedURLs().length,
|
||||
removedUrls: dataCollector.getRemovedURLs(),
|
||||
css,
|
||||
h: helpers,
|
||||
rootPath: '',
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ module.exports = {
|
|||
}
|
||||
|
||||
case 'remove.url': {
|
||||
dataCollector.removeUrl(message.url);
|
||||
dataCollector._removeUrl(message.url);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,18 @@ block content
|
|||
.row
|
||||
.column
|
||||
include runInfo
|
||||
.responsive
|
||||
table(data-sortable, id='pages')
|
||||
+rowHeading(headings)
|
||||
+rows(pages)
|
||||
if pages.length > 0
|
||||
.responsive
|
||||
table(data-sortable, id='pages')
|
||||
+rowHeading(headings)
|
||||
+rows(pages)
|
||||
|
||||
if removedUrls.length > 0
|
||||
p The following pages was removed because they passed the budget configuration.
|
||||
.responsive
|
||||
table(data-sortable, id='removedpages')
|
||||
+rowHeading(['URL'])
|
||||
each url in removedUrls
|
||||
tr
|
||||
td.url.pagesurl(data-title='URL')
|
||||
a(href= url)= decodeURIComponent(url)
|
||||
|
|
|
|||
Loading…
Reference in New Issue