diff --git a/dashboard/src/components/rmrk/Create/CreateCollection.vue b/dashboard/src/components/rmrk/Create/CreateCollection.vue
index 9689922353..8c764069e5 100644
--- a/dashboard/src/components/rmrk/Create/CreateCollection.vue
+++ b/dashboard/src/components/rmrk/Create/CreateCollection.vue
@@ -39,7 +39,7 @@
diff --git a/dashboard/src/components/rmrk/Gallery/Gallery.vue b/dashboard/src/components/rmrk/Gallery/Gallery.vue
index fa4014fc54..956faf72f1 100644
--- a/dashboard/src/components/rmrk/Gallery/Gallery.vue
+++ b/dashboard/src/components/rmrk/Gallery/Gallery.vue
@@ -29,7 +29,7 @@
@@ -47,9 +47,12 @@
-
+
{{ nft.name }}
+
+ {{ nft.name }} 「{{ nft.count }}」
+
@@ -70,7 +73,7 @@ import { NFTWithMeta, NFT } from '../service/scheme';
import { defaultSortBy, sanitizeObjectArray } from '../utils';
import GalleryCardList from './GalleryCardList.vue'
import Search from './Search/SearchBar.vue'
-import { basicFilter } from './Search/query'
+import { basicFilter, basicAggQuery } from './Search/query'
type NFTType = NFTWithMeta;
const components = { GalleryCardList, Search }
@@ -102,10 +105,10 @@ export default class Gallery extends Vue {
get results() {
if (this.searchQuery) {
- return basicFilter(this.searchQuery, this.nfts)
+ return basicAggQuery(basicFilter(this.searchQuery, this.nfts))
}
- return this.nfts
+ return basicAggQuery(this.nfts)
}
}
diff --git a/dashboard/src/components/rmrk/Gallery/GalleryRare.vue b/dashboard/src/components/rmrk/Gallery/GalleryRare.vue
index 418622f209..6591469bd8 100644
--- a/dashboard/src/components/rmrk/Gallery/GalleryRare.vue
+++ b/dashboard/src/components/rmrk/Gallery/GalleryRare.vue
@@ -28,7 +28,7 @@
diff --git a/dashboard/src/components/rmrk/Gallery/Search/query.ts b/dashboard/src/components/rmrk/Gallery/Search/query.ts
index 66f9fc5631..86ba0d651f 100644
--- a/dashboard/src/components/rmrk/Gallery/Search/query.ts
+++ b/dashboard/src/components/rmrk/Gallery/Search/query.ts
@@ -1,6 +1,8 @@
-import M, { Query } from 'mingo'
+import M, { Query, Aggregator } from 'mingo'
+import { Collection as Aggregation } from 'mingo/core'
import { NFTWithMeta } from '../../service/scheme'
+
type QueryType = Record
export const basicFilterQuery = (value: string): Query => {
@@ -20,9 +22,32 @@ export const basicFilterQuery = (value: string): Query => {
return new Query(criteria)
}
+export const basicAggregation = (): Aggregator => {
+ const agg: Aggregation = [
+ {
+ $group: {
+ _id: '$image',
+ ids: { $push: '$id' },
+ collection: { $first: '$collection' },
+ name: { $first: '$name' },
+ id: { $first: '$id' },
+ image: { $first: '$image' },
+ count: { $sum: 1 }
+ }
+ }
+ ]
+
+ return new Aggregator(agg);
+}
+
export const basicFilter = (value: string, ntfs: NFTWithMeta[]): any[] => {
const query = basicFilterQuery(value)
return query.find(ntfs).all()
}
+export const basicAggQuery = (ntfs: NFTWithMeta[]) => {
+ const query = basicAggregation()
+ return query.run(ntfs)
+}
+
diff --git a/dashboard/src/main.ts b/dashboard/src/main.ts
index e717fbf5ce..b46ff87471 100644
--- a/dashboard/src/main.ts
+++ b/dashboard/src/main.ts
@@ -26,6 +26,15 @@ import i18n from './i18n'
import mingo from 'mingo'
import api from './fetch'
+import { useOperators, OperatorType } from 'mingo/core'
+import { $match, $group, $project } from 'mingo/operators/pipeline'
+import { $sum, $first, $push } from 'mingo/operators/accumulator'
+
+// ensure the required operators are preloaded prior to using them.
+type OperatorMap = Record ;
+useOperators(OperatorType.PIPELINE, { $match, $group, $project } as OperatorMap)
+useOperators(OperatorType.ACCUMULATOR, { $sum, $first, $push } as OperatorMap)
+
Vue.filter('shortAddress', shortAddress);
(window as any).C = Connector;