feat: Show more locations if there are less submissions
All checks were successful
Build Docker / BuildImage (push) Successful in 38s

This commit is contained in:
2025-05-27 12:24:12 +10:00
parent e9cfbeffda
commit d53e0d423f

View File

@@ -312,10 +312,17 @@
const recentLocations = locations.filter(location => const recentLocations = locations.filter(location =>
new Date(location.date_added) > cutoffTime new Date(location.date_added) > cutoffTime
); );
if (recentLocations.length === 0) { // Update the list with summary
locationsList.innerHTML = '<p>No locations added in the last 48 hours.</p>'; locationsList.innerHTML = `<p>Showing ${recentLocations.length} locations from the last 48 hours. Click on markers to see details.</p>`;
return;
// If there are less than 10 recent locations, show the newest 10
if (recentLocations.length < 10) {
// Get the newest locations up to 10
recentLocations.sort((a, b) => new Date(b.date_added) - new Date(a.date_added));
recentLocations.splice(10);
locationsList.innerHTML = `<p>Showing the newest ${recentLocations.length} locations.</p>`;
} }
// Add markers for each location // Add markers for each location
@@ -323,8 +330,7 @@
addLocationToMap(location); addLocationToMap(location);
}); });
// Update the list with summary
locationsList.innerHTML = `<p>Showing ${recentLocations.length} locations from the last 48 hours. Click on markers to see details.</p>`;
}) })
.catch(error => { .catch(error => {
console.error('Error loading locations:', error); console.error('Error loading locations:', error);