mirror of
https://github.com/DeNNiiInc/Web-Page-Performance-Test.git
synced 2026-04-17 20:05:58 +00:00
Fix crashes in runner.js and git command in server.js
This commit is contained in:
@@ -15,7 +15,8 @@ async function initSchema() {
|
||||
scores JSONB NOT NULL,
|
||||
metrics JSONB NOT NULL,
|
||||
user_uuid TEXT NOT NULL,
|
||||
user_ip TEXT NOT NULL
|
||||
user_ip TEXT NOT NULL,
|
||||
filmstrip JSONB
|
||||
);
|
||||
`;
|
||||
await client.query(query);
|
||||
|
||||
@@ -150,20 +150,24 @@ async function _executeTest(url, options) {
|
||||
|
||||
|
||||
|
||||
// Safe property access
|
||||
const getScore = (cat) => (lhr.categories[cat] && lhr.categories[cat].score) ? lhr.categories[cat].score * 100 : 0;
|
||||
const getMetric = (aud) => (lhr.audits[aud] && lhr.audits[aud].numericValue) ? lhr.audits[aud].numericValue : 0;
|
||||
|
||||
const summary = {
|
||||
id: testId,
|
||||
url: lhr.finalUrl,
|
||||
timestamp: lhr.fetchTime,
|
||||
scores: {
|
||||
performance: lhr.categories.performance.score * 100,
|
||||
accessibility: lhr.categories.accessibility.score * 100,
|
||||
bestPractices: lhr.categories['best-practices'].score * 100,
|
||||
seo: lhr.categories.seo.score * 100,
|
||||
performance: getScore('performance'),
|
||||
accessibility: getScore('accessibility'),
|
||||
bestPractices: getScore('best-practices'),
|
||||
seo: getScore('seo'),
|
||||
},
|
||||
metrics: {
|
||||
lcp: lhr.audits['largest-contentful-paint'].numericValue,
|
||||
cls: lhr.audits['cumulative-layout-shift'].numericValue,
|
||||
tbt: lhr.audits['total-blocking-time'].numericValue,
|
||||
lcp: getMetric('largest-contentful-paint'),
|
||||
cls: getMetric('cumulative-layout-shift'),
|
||||
tbt: getMetric('total-blocking-time'),
|
||||
},
|
||||
userAgent: lhr.userAgent,
|
||||
isMobile: isMobile,
|
||||
@@ -221,15 +225,15 @@ async function _executeTest(url, options) {
|
||||
url: lhr.finalUrl,
|
||||
timestamp: lhr.fetchTime,
|
||||
scores: {
|
||||
performance: lhr.categories.performance.score * 100,
|
||||
accessibility: lhr.categories.accessibility.score * 100,
|
||||
bestPractices: lhr.categories['best-practices'].score * 100,
|
||||
seo: lhr.categories.seo.score * 100,
|
||||
performance: getScore('performance'),
|
||||
accessibility: getScore('accessibility'),
|
||||
bestPractices: getScore('best-practices'),
|
||||
seo: getScore('seo'),
|
||||
},
|
||||
metrics: {
|
||||
lcp: lhr.audits['largest-contentful-paint'].numericValue,
|
||||
cls: lhr.audits['cumulative-layout-shift'].numericValue,
|
||||
tbt: lhr.audits['total-blocking-time'].numericValue,
|
||||
lcp: getMetric('largest-contentful-paint'),
|
||||
cls: getMetric('cumulative-layout-shift'),
|
||||
tbt: getMetric('total-blocking-time'),
|
||||
},
|
||||
userAgent: lhr.userAgent,
|
||||
isMobile: isMobile,
|
||||
|
||||
Reference in New Issue
Block a user