* Rework user.js and User object to ES6

* Update download stats for user when web download is completed
This commit is contained in:
Bryan Ashby 2017-02-18 13:21:18 -07:00
parent 6406d32165
commit 058ff3f367
14 changed files with 569 additions and 516 deletions

View file

@ -17,7 +17,6 @@ global args:
where <command> is one of:
user : user utilities
config : config file management
file-base
fb : file base management
`,
@ -39,7 +38,7 @@ valid args:
--new : generate a new/initial configuration
`,
FileBase :
`usage: oputil.js file-base <action> [<args>] [<action_specific>]
`usage: oputil.js fb <action> [<args>] [<action_specific>]
where <action> is one of:
scan <args> AREA_TAG : (re)scan area specified by AREA_TAG for new files
@ -47,6 +46,8 @@ where <action> is one of:
valid scan <args>:
--tags TAG1,TAG2,... : specify tag(s) to assign to discovered entries
ARE_TAG can optionally contain @STORAGE_TAG; for example: retro_pc@bbs
`
};

View file

@ -34,7 +34,6 @@ module.exports = function() {
handleConfigCommand();
break;
case 'file-base' :
case 'fb' :
handleFileBaseCommand();
break;

View file

@ -7,8 +7,8 @@ const ExitCodes = require('./oputil_common.js').ExitCodes;
const argv = require('./oputil_common.js').argv;
const initConfigAndDatabases = require('./oputil_common.js').initConfigAndDatabases;
const async = require('async');
const _ = require('lodash');
exports.handleUserCommand = handleUserCommand;
@ -55,13 +55,13 @@ function handleUserCommand() {
}
function getUser(userName, cb) {
const user = require('./core/user.js');
user.getUserIdAndName(argv.user, function userNameAndId(err, userId) {
const User = require('../../core/user.js');
User.getUserIdAndName(argv.user, function userNameAndId(err, userId) {
if(err) {
process.exitCode = ExitCodes.BAD_ARGS;
return cb(new Error('Failed to retrieve user'));
} else {
let u = new user.User();
let u = new User();
u.userId = userId;
return cb(null, u);
}
@ -97,7 +97,7 @@ function setAccountStatus(userName, active) {
initAndGetUser(argv.user, callback);
},
function activateUser(user, callback) {
const AccountStatus = require('./core/user.js').User.AccountStatus;
const AccountStatus = require('../../core/user.js').AccountStatus;
user.persistProperty('account_status', active ? AccountStatus.active : AccountStatus.inactive, callback);
}
],