Use published_at for pruning and search radius
This commit is contained in:
parent
0bd4988ad7
commit
bc9700d522
|
|
@ -134,7 +134,13 @@ function filterByBounds(posts, map) {
|
||||||
|
|
||||||
|
|
||||||
function getPostTimeMs(p) {
|
function getPostTimeMs(p) {
|
||||||
const raw = p?.created_at || p?.CreatedAt || p?.createdAt || p?.published_at;
|
const raw =
|
||||||
|
p?.published_at ||
|
||||||
|
p?.publishedAt ||
|
||||||
|
p?.PublishedAt ||
|
||||||
|
p?.created_at ||
|
||||||
|
p?.CreatedAt ||
|
||||||
|
p?.createdAt;
|
||||||
if (!raw) return 0;
|
if (!raw) return 0;
|
||||||
const d = raw instanceof Date ? raw : new Date(String(raw));
|
const d = raw instanceof Date ? raw : new Date(String(raw));
|
||||||
if (Number.isNaN(d.getTime())) return 0;
|
if (Number.isNaN(d.getTime())) return 0;
|
||||||
|
|
@ -1094,15 +1100,26 @@ export function usePostsEngine({
|
||||||
const map = mapRef.current;
|
const map = mapRef.current;
|
||||||
let lat;
|
let lat;
|
||||||
let lon;
|
let lon;
|
||||||
|
let radiusKm;
|
||||||
try {
|
try {
|
||||||
const center = map?.getCenter?.();
|
const view = map ? getViewFromMap(map) : null;
|
||||||
lat = center?.lat;
|
if (view?.center) {
|
||||||
lon = center?.lng;
|
lon = view.center[0];
|
||||||
|
lat = view.center[1];
|
||||||
|
} else {
|
||||||
|
const center = map?.getCenter?.();
|
||||||
|
lat = center?.lat;
|
||||||
|
lon = center?.lng;
|
||||||
|
}
|
||||||
|
if (view?.radiusKm) {
|
||||||
|
radiusKm = Math.min(Math.max(view.radiusKm * 1.2, 25), 2500);
|
||||||
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
const data = await fetchUnifiedSearch(q, {
|
const data = await fetchUnifiedSearch(q, {
|
||||||
type: "posts",
|
type: "posts",
|
||||||
lat,
|
lat,
|
||||||
lon,
|
lon,
|
||||||
|
radius_km: radiusKm,
|
||||||
limit: 60,
|
limit: 60,
|
||||||
});
|
});
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue