Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/be/refactor request pagespeed, resolves #1085 #1086

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions Server/service/networkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class NetworkService {
httpResponse.code = code;
httpResponse.status = false;
httpResponse.message = this.http.STATUS_CODES[code] || "Network Error";

return httpResponse;
}
httpResponse.status = true;
Expand All @@ -153,31 +152,10 @@ class NetworkService {
*/
async requestPagespeed(job) {
const url = job.data.url;
const { response, responseTime, error } = await this.timeRequest(() =>
this.axios.get(
`https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&category=seo&category=accessibility&category=best-practices&category=performance`
)
);

const pagespeedResponse = {
monitorId: job.data._id,
type: job.data.type,
responseTime,
payload: response?.data,
};

if (error) {
const code = error.response?.status || this.NETWORK_ERROR;
pagespeedResponse.code = code;
pagespeedResponse.status = false;
pagespeedResponse.message = this.http.STATUS_CODES[code] || "Network Error";
return pagespeedResponse;
}

pagespeedResponse.status = true;
pagespeedResponse.code = response.status;
pagespeedResponse.message = this.http.STATUS_CODES[response.status];
return pagespeedResponse;
const updatedJob = { ...job };
const pagespeedUrl = `https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&category=seo&category=accessibility&category=best-practices&category=performance`;
updatedJob.data.url = pagespeedUrl;
return this.requestHttp(updatedJob);
}

async requestHardware(job) {
Expand Down
8 changes: 4 additions & 4 deletions Server/service/statusService.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class StatusService {
}

if (type === "hardware") {
check.cpu = payload.cpu;
check.memory = payload.memory;
check.disk = payload.disk;
check.host = payload.host;
check.cpu = payload?.cpu ?? {};
check.memory = payload?.memory ?? {};
check.disk = payload?.disk ?? {};
check.host = payload?.host ?? {};
}
return check;
};
Expand Down