Only fetch published photos and locations
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
- Globally for photos - For sitemap locations and photos
This commit is contained in:
@@ -47,13 +47,13 @@ export async function get (req, res, next) {
|
||||
baseURL = `http${(req.httpVersion >= 2) ? 's' : ''}://${req.headers.host}`
|
||||
|
||||
// Get locations
|
||||
const locationsReq = await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug,modified_on`)
|
||||
const locationsReq = await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug,modified_on&status=published`)
|
||||
const locationsData = await locationsReq.json()
|
||||
const locations = locationsData.data
|
||||
|
||||
// Add last modified date to each location from its last photo
|
||||
const updatedLocations = locations.map(async (location, i) => {
|
||||
const latestPhotoReq = await fetch(`${apiEndpoints.rest}/items/photos?fields=created_on&limit=1&sort=created_on&filter[location.slug][rlike]=%${location.slug}`)
|
||||
const latestPhotoReq = await fetch(`${apiEndpoints.rest}/items/photos?fields=created_on&limit=1&sort=created_on&status=published&filter[location.slug][rlike]=%${location.slug}`)
|
||||
const latestPhotoData = await latestPhotoReq.json()
|
||||
const latestPhoto = latestPhotoData.data[0]
|
||||
location.updated = latestPhoto ? latestPhoto.created_on : location.modified_on
|
||||
|
||||
Reference in New Issue
Block a user