fix: use foreach because filter isnt available on prod???
All checks were successful
create archive with lfs / tag (push) Successful in 4s
All checks were successful
create archive with lfs / tag (push) Successful in 4s
This commit is contained in:
parent
4e24899c0f
commit
f597722892
@ -45,19 +45,14 @@ export const addLastVisitor = (request: Request, cookies: Cookies) => {
|
|||||||
const _addLastVisitor = (visitors: Map<string, Visitor>, request: Request, cookies: Cookies) => {
|
const _addLastVisitor = (visitors: Map<string, Visitor>, request: Request, cookies: Cookies) => {
|
||||||
const currentTime = Date.now()
|
const currentTime = Date.now()
|
||||||
// filter out old entries
|
// filter out old entries
|
||||||
visitors = new Map(
|
visitors.forEach((visitor, id, map) => {
|
||||||
visitors.entries().filter(
|
if (currentTime - visitor.visits[0] > 1000 * VISITOR_EXPIRY_SECONDS)
|
||||||
([_, visitor]) =>
|
map.delete(id)
|
||||||
{ return currentTime - visitor.visits[0] < 1000 * VISITOR_EXPIRY_SECONDS }
|
else
|
||||||
).map(
|
visitor.visits = visitor.visits.filter((since) => {
|
||||||
([id, visitor]) => {
|
return currentTime - since < 1000 * VISITOR_EXPIRY_SECONDS
|
||||||
visitor.visits = visitor.visits.filter((since) => {
|
})
|
||||||
return currentTime - since < 1000 * VISITOR_EXPIRY_SECONDS
|
})
|
||||||
})
|
|
||||||
return [id, visitor]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// check whether the request is from a bot or not (this doesnt need to be accurate we just want to filter out honest bots)
|
// check whether the request is from a bot or not (this doesnt need to be accurate we just want to filter out honest bots)
|
||||||
if (isBot(request)) { return visitors }
|
if (isBot(request)) { return visitors }
|
||||||
const scopedCookies = scopeCookies(cookies, '/')
|
const scopedCookies = scopeCookies(cookies, '/')
|
||||||
|
Loading…
Reference in New Issue
Block a user