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,
|
scores JSONB NOT NULL,
|
||||||
metrics JSONB NOT NULL,
|
metrics JSONB NOT NULL,
|
||||||
user_uuid TEXT NOT NULL,
|
user_uuid TEXT NOT NULL,
|
||||||
user_ip TEXT NOT NULL
|
user_ip TEXT NOT NULL,
|
||||||
|
filmstrip JSONB
|
||||||
);
|
);
|
||||||
`;
|
`;
|
||||||
await client.query(query);
|
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 = {
|
const summary = {
|
||||||
id: testId,
|
id: testId,
|
||||||
url: lhr.finalUrl,
|
url: lhr.finalUrl,
|
||||||
timestamp: lhr.fetchTime,
|
timestamp: lhr.fetchTime,
|
||||||
scores: {
|
scores: {
|
||||||
performance: lhr.categories.performance.score * 100,
|
performance: getScore('performance'),
|
||||||
accessibility: lhr.categories.accessibility.score * 100,
|
accessibility: getScore('accessibility'),
|
||||||
bestPractices: lhr.categories['best-practices'].score * 100,
|
bestPractices: getScore('best-practices'),
|
||||||
seo: lhr.categories.seo.score * 100,
|
seo: getScore('seo'),
|
||||||
},
|
},
|
||||||
metrics: {
|
metrics: {
|
||||||
lcp: lhr.audits['largest-contentful-paint'].numericValue,
|
lcp: getMetric('largest-contentful-paint'),
|
||||||
cls: lhr.audits['cumulative-layout-shift'].numericValue,
|
cls: getMetric('cumulative-layout-shift'),
|
||||||
tbt: lhr.audits['total-blocking-time'].numericValue,
|
tbt: getMetric('total-blocking-time'),
|
||||||
},
|
},
|
||||||
userAgent: lhr.userAgent,
|
userAgent: lhr.userAgent,
|
||||||
isMobile: isMobile,
|
isMobile: isMobile,
|
||||||
@@ -221,15 +225,15 @@ async function _executeTest(url, options) {
|
|||||||
url: lhr.finalUrl,
|
url: lhr.finalUrl,
|
||||||
timestamp: lhr.fetchTime,
|
timestamp: lhr.fetchTime,
|
||||||
scores: {
|
scores: {
|
||||||
performance: lhr.categories.performance.score * 100,
|
performance: getScore('performance'),
|
||||||
accessibility: lhr.categories.accessibility.score * 100,
|
accessibility: getScore('accessibility'),
|
||||||
bestPractices: lhr.categories['best-practices'].score * 100,
|
bestPractices: getScore('best-practices'),
|
||||||
seo: lhr.categories.seo.score * 100,
|
seo: getScore('seo'),
|
||||||
},
|
},
|
||||||
metrics: {
|
metrics: {
|
||||||
lcp: lhr.audits['largest-contentful-paint'].numericValue,
|
lcp: getMetric('largest-contentful-paint'),
|
||||||
cls: lhr.audits['cumulative-layout-shift'].numericValue,
|
cls: getMetric('cumulative-layout-shift'),
|
||||||
tbt: lhr.audits['total-blocking-time'].numericValue,
|
tbt: getMetric('total-blocking-time'),
|
||||||
},
|
},
|
||||||
userAgent: lhr.userAgent,
|
userAgent: lhr.userAgent,
|
||||||
isMobile: isMobile,
|
isMobile: isMobile,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ app.use('/reports', express.static(path.join(__dirname, 'reports')));
|
|||||||
|
|
||||||
// API Endpoint: Git Info
|
// API Endpoint: Git Info
|
||||||
app.get("/api/git-info", (req, res) => {
|
app.get("/api/git-info", (req, res) => {
|
||||||
exec('/usr/bin/git log -1 --format="%H|%cr"', (error, stdout, stderr) => {
|
exec('git log -1 --format="%H|%cr"', (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error("Error getting git info:", error);
|
console.error("Error getting git info:", error);
|
||||||
console.error("Stderr:", stderr);
|
console.error("Stderr:", stderr);
|
||||||
|
|||||||
Reference in New Issue
Block a user