Use filtered aggregated photos count on Location page
This commit is contained in:
@@ -271,21 +271,19 @@
|
|||||||
date_created
|
date_created
|
||||||
}
|
}
|
||||||
|
|
||||||
total_published: photo_aggregated (groupBy: "location") {
|
total_published: photo_aggregated (filter: { location: { slug: { _eq: "${location}" }}}) {
|
||||||
group
|
count { location }
|
||||||
count { id }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
const { data } = res
|
const { data } = res
|
||||||
const photosCount = stuff.countTotalPhotosByLocation.find((total: any) => total.group.location === Number(data.location[0].id))
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
location: data.location[0],
|
location: data.location[0],
|
||||||
photos: data.photos,
|
photos: data.photos,
|
||||||
totalPhotos: data.photos.length ? photosCount.count.id : 0,
|
totalPhotos: data.photos.length ? data.total_published[0].count.location : 0,
|
||||||
lastUpdated: data.photos.length ? data.photos[0].date_created : undefined,
|
lastUpdated: data.photos.length ? data.photos[0].date_created : undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user