Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
durationAllTimes({ aom = null, startDate = '2019-01-01T00:00:00Z' }) {
const $match = {
'passenger.start.datetime': { $gte: startDate, $lt: new Date() },
};
if (aom) $match['aom._id'] = aom;
const args = [
{
$match,
},
{
$group: {
_id: {
name: 'duration',
},
total: {
$sum: { $max: ['$passenger.duration', '$passenger.calc_duration'] },
},
},
},
];
durationPerDay({ aom = null, startDate = '2019-01-01T00:00:00Z' }) {
const $match = {
'passenger.start.datetime': { $gte: startDate, $lt: new Date() },
};
if (aom) $match['aom._id'] = aom;
const args = [
{
$match,
},
{
$project: {
year: { $year: '$passenger.start.datetime' },
month: { $month: '$passenger.start.datetime' },
day: { $dayOfMonth: '$passenger.start.datetime' },
duration: { $max: ['$passenger.duration', '$passenger.calc_duration'] },
},
},
{
$group: {
_id: {
journeysPerDay({ aom = null, startDate = '2019-01-01T00:00:00Z' }) {
const $match = {
'passenger.start.datetime': { $gte: startDate, $lt: new Date() },
};
if (aom) $match['aom._id'] = aom;
const args = [
{
$match,
},
{
$project: {
year: { $year: '$passenger.start.datetime' },
month: { $month: '$passenger.start.datetime' },
day: { $dayOfMonth: '$passenger.start.datetime' },
},
},
{
$group: {
_id: {
name: 'journeys_per_day',
journeysPerMonth({ aom = null, startDate = '2019-01-01T00:00:00Z' }) {
const $match = {
'passenger.start.datetime': { $gte: startDate, $lt: new Date() },
};
if (aom) $match['aom._id'] = aom;
const args = [
{
$match,
},
{
$project: {
year: { $year: '$passenger.start.datetime' },
month: { $month: '$passenger.start.datetime' },
},
},
{
$group: {
_id: {
name: 'journeys_per_month',
year: '$year',
distanceAllTimes({ aom = null, startDate = '2019-01-01T00:00:00Z' }) {
const $match = {
'passenger.start.datetime': { $gte: startDate, $lt: new Date() },
};
if (aom) $match['aom._id'] = aom;
const args = [
{
$match,
},
{
$group: {
_id: {
name: 'distance',
},
total: {
$sum: { $max: ['$passenger.distance', '$passenger.calc_distance'] },
},
},
},
];
distancePerMonth({ aom = null, startDate = '2019-01-01T00:00:00Z' }) {
const $match = {
'passenger.start.datetime': { $gte: startDate, $lt: new Date() },
};
if (aom) $match['aom._id'] = aom;
const args = [
{
$match,
},
{
$project: {
year: { $year: '$passenger.start.datetime' },
month: { $month: '$passenger.start.datetime' },
distance: { $max: ['$passenger.distance', '$passenger.calc_distance'] },
},
},
{
$group: {
_id: {
name: 'distance_per_day',
journeysAllTimes({ aom = null, startDate = '2019-01-01T00:00:00Z' }) {
const args = {
'passenger.start.datetime': { $gte: startDate, $lt: new Date() },
};
if (aom) args['aom._id'] = aom;
return {
collection: 'journeys',
commands: [
{
args,
command: 'find',
},
{
command: 'count',
},
],
};
},
};
distancePerDay({ aom = null, startDate = '2019-01-01T00:00:00Z' }) {
const $match = {
'passenger.start.datetime': { $gte: startDate, $lt: new Date() },
};
if (aom) $match['aom._id'] = aom;
const args = [
{
$match,
},
{
$project: {
year: { $year: '$passenger.start.datetime' },
month: { $month: '$passenger.start.datetime' },
day: { $dayOfMonth: '$passenger.start.datetime' },
distance: { $max: ['$passenger.distance', '$passenger.calc_distance'] },
},
},
{
$group: {
_id: {