master
Mark Moffat 2020-03-19 21:05:46 +10:30
parent e4a34b5439
commit 1b030dce27
2 changed files with 4 additions and 5 deletions

View File

@ -165,8 +165,7 @@ router.get('/admin/dashboard', csrfProtection, restrict, async (req, res) => {
{ $project: { o: { $objectToArray: '$orderProducts' } } }, { $project: { o: { $objectToArray: '$orderProducts' } } },
{ $unwind: '$o' }, { $unwind: '$o' },
{ $group: { { $group: {
_id: '$o.v.productId', _id: '$o.v.title',
title: { $last: '$o.v.title' },
productImage: { $last: '$o.v.productImage' }, productImage: { $last: '$o.v.productImage' },
count: { $sum: '$o.v.quantity' } count: { $sum: '$o.v.quantity' }
} }, } },

View File

@ -57,12 +57,12 @@
{{#each dashboardData.topProducts}} {{#each dashboardData.topProducts}}
<li class="media my-4 align-middle"> <li class="media my-4 align-middle">
{{#if this.productImage}} {{#if this.productImage}}
<img src="{{this.productImage}}" class="col-2 mr-3 img-fluid" alt="image {{this.productTitle}}"> <img src="{{this.productImage}}" class="col-2 mr-3 img-fluid" alt="image {{this._id}}">
{{else}} {{else}}
<img src="/images/placeholder.png" class="col-2 mr-3 img-fluid" alt="mage {{this.productTitle}}"> <img src="/images/placeholder.png" class="col-2 mr-3 img-fluid" alt="mage {{this._id}}">
{{/if}} {{/if}}
<div class="media-body"> <div class="media-body">
<h5 class="mt-3 mb-1">{{this.title}}</h5> <h5 class="mt-3 mb-1">{{this._id}}</h5>
<h4 class="mt-4">Sold: <span class="text-danger">{{this.count}}</span></h4> <h4 class="mt-4">Sold: <span class="text-danger">{{this.count}}</span></h4>
</div> </div>
</li> </li>