Fix crashes in runner.js and git command in server.js

This commit is contained in:
2025-12-29 10:54:59 +11:00
parent 4c888b0500
commit da6c67b72d
3 changed files with 21 additions and 16 deletions

View File

@@ -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);

View File

@@ -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,

View File

@@ -14,7 +14,7 @@ app.use('/reports', express.static(path.join(__dirname, 'reports')));
// API Endpoint: Git Info
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) {
console.error("Error getting git info:", error);
console.error("Stderr:", stderr);