Skip to content

Commit

Permalink
Merge pull request #215 from poap-xyz/release/v1.12.8
Browse files Browse the repository at this point in the history
Release v1.12.8
  • Loading branch information
jm42 authored May 2, 2024
2 parents 16716c3 + 2c43b37 commit 1615bc7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
11 changes: 10 additions & 1 deletion netlify/edge-functions/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export default async function handler(request, context) {
const eventId = parseEventId(rawEventId)
const env = getEnv(context)

if (String(eventId) !== String(rawEventId)) {
return new Response(html, {
status: 400,
headers: {
'content-type': 'text/html',
},
})
}

let eventInfo
try {
eventInfo = await getEventInfo(eventId, env)
Expand All @@ -41,7 +50,7 @@ export default async function handler(request, context) {

if (eventInfo == null) {
return new Response(html, {
status: 404,
status: 200,
headers: {
'content-type': 'text/html',
},
Expand Down
22 changes: 21 additions & 1 deletion netlify/edge-functions/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,32 @@ export default async function handler(request, context) {
})
}

if (eventsInfo == null) {
return new Response(html, {
status: 200,
headers: {
'content-type': 'text/html',
},
})
}

let totalSupply = 0
let totalReservations = 0
let names = []
let ts = 0

for (const eventInfo of Object.values(eventsInfo)) {
for (const eventId of eventIds) {
const eventInfo = eventsInfo[eventId]

if (eventInfo.event == null || eventInfo.owners == null || eventInfo.metrics == null) {
return new Response(html, {
status: 200,
headers: {
'content-type': 'text/html',
},
})
}

totalSupply += eventInfo.owners.length
totalReservations += eventInfo.metrics?.emailReservations ?? 0
names = [...names, eventInfo.event.name]
Expand Down
4 changes: 2 additions & 2 deletions netlify/loaders/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export async function getEventInfo(eventId, env) {
return null
}
const response = await fetch(
`${env.FAMILY_API_URL}/event/${eventId}?description=false&metrics=true&fresh=false&refresh=false`,
`${env.FAMILY_API_URL}/event/${eventId}?description=false&metrics=true&fresh=false&refresh=true`,
{
headers: {
'x-api-key': env.FAMILY_API_KEY,
Expand Down Expand Up @@ -64,7 +64,7 @@ export async function getEvents(eventIds, env) {
return null
}
const response = await fetch(
`${env.FAMILY_API_URL}/events/${eventIds.map((eventId) => encodeURIComponent(eventId)).join(',')}?fresh=false`,
`${env.FAMILY_API_URL}/events/${eventIds.map((eventId) => encodeURIComponent(eventId)).join(',')}?fresh=true`,
{
headers: {
'x-api-key': env.FAMILY_API_KEY,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/poap-family",
"version": "1.12.7",
"version": "1.12.8",
"author": {
"name": "POAP",
"url": "https://poap.xyz"
Expand Down

0 comments on commit 1615bc7

Please sign in to comment.