Skip to content

Commit

Permalink
refactor(scan): move field stat types from hardcode in viewer to fiel…
Browse files Browse the repository at this point in the history
…ds list
  • Loading branch information
popstas committed Mar 13, 2021
1 parent 0d5fd47 commit ff59c99
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions src/presets/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const fields = [
validate: {
error: '== 0',
},
stat: {
type: 'enum',
},
groups: ['canonical'],
type: 'boolean',
},
Expand All @@ -43,6 +46,9 @@ const fields = [
comment_en: 'Scan depth',
groups: ['info'],
type: 'integer',
stat: {
type: 'enum',
},
},
{
name: 'status',
Expand All @@ -51,6 +57,9 @@ const fields = [
validate: {
error: '!= 200',
},
stat: {
type: 'enum',
},
groups: ['info'],
type: 'integer',
},
Expand All @@ -62,6 +71,10 @@ const fields = [
warning: '> 500',
error: '> 1000',
},
stat: {
type: 'ranges',
ranges: ['< 100', '100-499', '500-999', '1000-2000', '> 2000']
},
groups: ['perf'],
type: 'integer',
},
Expand All @@ -71,13 +84,19 @@ const fields = [
/*validate: {
error: 'len() == 0' // TODO:
},*/
stat: {
type: 'unique',
},
groups: ['metatags'],
align: 'right',
},
{
name: 'h1',
comment: 'h1',
comment_en: 'h1',
stat: {
type: 'unique',
},
groups: ['seo', 'metatags'],
},
{
Expand All @@ -92,11 +111,17 @@ const fields = [
/*validate: {
warning: 'len() > 256',
},*/
stat: {
type: 'unique',
},
groups: ['metatags'],
},
{
name: 'keywords',
comment: 'Keywords',
stat: {
type: 'unique',
},
groups: ['metatags'],
},
{
Expand Down Expand Up @@ -124,6 +149,9 @@ const fields = [
warning: '== 0',
error: '> 1',
},
stat: {
type: 'enum',
},
groups: ['seo'],
type: 'integer',
},
Expand Down Expand Up @@ -155,6 +183,9 @@ const fields = [
validate: {
warning: '> 1',
},
stat: {
type: 'enum',
},
groups: ['canonical'],
type: 'integer',
},
Expand All @@ -164,6 +195,9 @@ const fields = [
validate: {
warning: '< 1',
},
stat: {
type: 'enum',
},
groups: ['metatags'],
type: 'integer',
},
Expand Down Expand Up @@ -233,6 +267,9 @@ const fields = [
validate: {
warning: '< 5'
},
stat: {
type: 'average',
},
type: 'integer',
},
{
Expand All @@ -243,6 +280,10 @@ const fields = [
warning: '> 1500',
error: '> 3000',
},
stat: {
type: 'ranges',
ranges: ['< 500', '500-1499', '1500-3000', '> 3000']
},
groups: ['perf'],
type: 'integer',
},
Expand All @@ -254,6 +295,10 @@ const fields = [
warning: '> 500000',
error: '> 1000000',
},
stat: {
type: 'ranges',
ranges: ['< 100000', '100000-500000', '> 500000']
},
groups: ['perf'],
type: 'integer',
},
Expand All @@ -264,6 +309,10 @@ const fields = [
comment_en: 'Lighthouse: Performance',
groups: ['Lighthouse: Main'],
type: 'integer',
stat: {
type: 'ranges',
ranges: ['< 50', '50-89', '90-100']
},
},
{
name: 'lighthouse_scores_pwa',
Expand Down
2 changes: 1 addition & 1 deletion src/scrap-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = async (baseUrl, options = {}) => {
const protocol = url.parse(baseUrl).protocol;

const log = (msg) => {
const socketId = options.socket ? `options.socket.id ` : '';
const socketId = options.socket ? `${options.socket.id} ` : '';
if (DEBUG) console.log(`${socketId}${msg}`);
socketSend(options.socket, 'status', msg);
};
Expand Down

0 comments on commit ff59c99

Please sign in to comment.