implemented review suggestions

This commit is contained in:
courage173
2021-01-14 16:13:45 +01:00
parent 7a0e6ca333
commit 2148f01f8d
7 changed files with 13 additions and 19 deletions

View File

@@ -369,15 +369,6 @@ router.put(
data,
unsetData
);
// if (
// data.lighthouseScanStatus &&
// data.lighthouseScanStatus === 'scan'
// ) {
// await LighthouseLogService.updateManyBy(
// { monitorId: req.params.monitorId },
// { scanning: true }
// );
// }
if (monitor) {
return sendItemResponse(req, res, monitor);
} else {

View File

@@ -335,7 +335,8 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
);
await LighthouseLogService.updateAllLighthouseLogs(
data.monitor.projectId,
data.monitorId
data.monitorId,
{ scanning: true }
);
} else {
await MonitorService.updateOneBy(

View File

@@ -204,12 +204,9 @@ module.exports = {
throw error;
}
},
async updateAllLighthouseLogs(projectId, monitorId) {
async updateAllLighthouseLogs(projectId, monitorId, query) {
try {
await this.updateManyBy(
{ monitorId: monitorId },
{ scanning: true }
);
await this.updateManyBy({ monitorId: monitorId }, query);
const logs = await this.findLastestScan({
monitorId,
url: null,

View File

@@ -228,7 +228,6 @@ export function editMonitorSuccess(newMonitor) {
if (newMonitor.lighthouseScanStatus === 'scanning') {
fetchLighthouseLogs(newMonitor.projectId._id, newMonitor._id, 0, 5);
}
console.log(newMonitor.lighthouseScanStatus, 'edit monitor');
return {
type: types.EDIT_MONITOR_SUCCESS,
payload: newMonitor,
@@ -854,7 +853,6 @@ export function getMonitorLogsFailure(error) {
// Fetch Lighthouse Logs list
export function fetchLighthouseLogs(projectId, monitorId, skip, limit, url) {
console.log('running')
return function(dispatch) {
const promise = getApi(
url

View File

@@ -89,7 +89,6 @@ export function updatelighthouselogbysocket(log) {
}
export function updateAlllighthouselogbysocket(log) {
console.log(log, 'all lighthouse logs')
return function(dispatch) {
dispatch({
type: 'UPDATE_ALL_LIGHTHOUSE_LOG',

View File

@@ -1085,6 +1085,14 @@ export default function monitor(state = INITIAL_STATE, action) {
monitor.monitors =
monitor._id === action.payload.projectId
? monitor.monitors.map(monitor => {
if (
monitor.data &&
monitor.data.url ===
action.payload.data.url
) {
monitor.currentLighthouseLog =
action.payload.data;
}
if (
monitor._id ===
action.payload.monitorId

View File

@@ -44,7 +44,7 @@
"scripts": {
"start": "npm run build && node index.js",
"build": "react-scripts build",
"dev": "export PORT=3006 && react-scripts start",
"dev": "set PORT=3006 && react-scripts start",
"test": "mocha --exit ./src/test/statusPage.test.js",
"eject": "react-scripts eject",
"snapshots": "cross-env CI=true react-scripts test --env=jsdom --coverage --coverage",