From 1b030dce2719b27e0f82073ddf669986e050df2d Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Thu, 19 Mar 2020 21:05:46 +1030 Subject: [PATCH] Fixes #128 --- routes/admin.js | 3 +-- views/dashboard.hbs | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/routes/admin.js b/routes/admin.js index d8df3d7..706c098 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -165,8 +165,7 @@ router.get('/admin/dashboard', csrfProtection, restrict, async (req, res) => { { $project: { o: { $objectToArray: '$orderProducts' } } }, { $unwind: '$o' }, { $group: { - _id: '$o.v.productId', - title: { $last: '$o.v.title' }, + _id: '$o.v.title', productImage: { $last: '$o.v.productImage' }, count: { $sum: '$o.v.quantity' } } }, diff --git a/views/dashboard.hbs b/views/dashboard.hbs index 79528a9..706466c 100644 --- a/views/dashboard.hbs +++ b/views/dashboard.hbs @@ -57,12 +57,12 @@ {{#each dashboardData.topProducts}}
  • {{#if this.productImage}} - image {{this.productTitle}} + image {{this._id}} {{else}} - mage {{this.productTitle}} + mage {{this._id}} {{/if}}
    -
    {{this.title}}
    +
    {{this._id}}

    Sold: {{this.count}}