updated stats controller
This commit is contained in:
parent
c901ced94c
commit
c201e1ecfd
2 changed files with 8 additions and 8 deletions
|
@ -90,18 +90,18 @@ module.exports = {
|
||||||
let totalSuccess = 0;
|
let totalSuccess = 0;
|
||||||
let totalFailure = 0;
|
let totalFailure = 0;
|
||||||
let percentSuccess;
|
let percentSuccess;
|
||||||
// sumarise the data
|
// summarise the data
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
let key = data[i].action + data[i].url;
|
let key = data[i].action + data[i].url;
|
||||||
totalCount += 1;
|
totalCount += 1;
|
||||||
switch (data[i].action) {
|
switch (data[i].action) {
|
||||||
case 'serve':
|
case 'SERVE':
|
||||||
totalServe += 1;
|
totalServe += 1;
|
||||||
break;
|
break;
|
||||||
case 'publish':
|
case 'PUBLISH':
|
||||||
totalPublish += 1;
|
totalPublish += 1;
|
||||||
break;
|
break;
|
||||||
case 'show':
|
case 'SHOW':
|
||||||
totalShow += 1;
|
totalShow += 1;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
|
|
|
@ -27,7 +27,7 @@ module.exports = (app, siofu, hostedContentPath) => {
|
||||||
// listener for when file upload encounters an error
|
// listener for when file upload encounters an error
|
||||||
uploader.on('error', ({ error }) => {
|
uploader.on('error', ({ error }) => {
|
||||||
logger.error('an error occured while uploading', error);
|
logger.error('an error occured while uploading', error);
|
||||||
postToStats('publish', '/', null, null, null, error);
|
postToStats('PUBLISH', '/', null, null, null, error);
|
||||||
socket.emit('publish-status', error);
|
socket.emit('publish-status', error);
|
||||||
});
|
});
|
||||||
// listener for when file has been uploaded
|
// listener for when file has been uploaded
|
||||||
|
@ -40,18 +40,18 @@ module.exports = (app, siofu, hostedContentPath) => {
|
||||||
// publish the file
|
// publish the file
|
||||||
publishController.publish(publishParams, file.name, file.meta.type)
|
publishController.publish(publishParams, file.name, file.meta.type)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
postToStats('publish', '/', null, null, null, 'success');
|
postToStats('PUBLISH', '/', null, null, null, 'success');
|
||||||
socket.emit('publish-complete', { name: publishParams.name, result });
|
socket.emit('publish-complete', { name: publishParams.name, result });
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
error = errorHandlers.handlePublishError(error);
|
error = errorHandlers.handlePublishError(error);
|
||||||
postToStats('publish', '/', null, null, null, error);
|
postToStats('PUBLISH', '/', null, null, null, error);
|
||||||
socket.emit('publish-failure', error);
|
socket.emit('publish-failure', error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logger.error(`An error occurred in uploading the client's file`);
|
logger.error(`An error occurred in uploading the client's file`);
|
||||||
socket.emit('publish-failure', 'File uploaded, but with errors');
|
socket.emit('publish-failure', 'File uploaded, but with errors');
|
||||||
postToStats('publish', '/', null, null, null, 'File uploaded, but with errors');
|
postToStats('PUBLISH', '/', null, null, null, 'File uploaded, but with errors');
|
||||||
// to-do: remove the file if not done automatically
|
// to-do: remove the file if not done automatically
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue