2019-03-11 03:19:36 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const moment = require('moment');
|
|
|
|
|
|
|
|
const formatters = {
|
|
|
|
site: site => site.name,
|
|
|
|
date: (date, column) => moment(date).format(column.format || 'MMM DD, YYYY'),
|
|
|
|
actors: actors => actors.join(', '),
|
|
|
|
rating: (rating) => {
|
2019-03-18 03:46:53 +00:00
|
|
|
if (rating === null) {
|
|
|
|
return '\x1b[90mNot available\x1b[0m';
|
|
|
|
}
|
|
|
|
|
2019-03-11 03:19:36 +00:00
|
|
|
if (rating.stars === null) {
|
2019-03-11 03:51:28 +00:00
|
|
|
return '\x1b[90mUnrated\x1b[0m';
|
2019-03-11 03:19:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rating.likes === null || rating.dislikes === null) {
|
2019-03-11 03:51:28 +00:00
|
|
|
return `\x1b[93m★ ${rating.stars.toFixed(2)}\x1b[0m`;
|
2019-03-11 03:19:36 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 03:51:28 +00:00
|
|
|
return `\x1b[93m★\x1b[0m ${rating.stars.toFixed(2)} \x1b[92m▲\x1b[0m ${String(rating.likes).padEnd(3)} \x1b[31m▼\x1b[0m ${String(rating.dislikes).padEnd(3)}`;
|
2019-03-11 03:19:36 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = formatters;
|