Skip to content

Commit

Permalink
Merge pull request #401 from poap-xyz/release/v1.16.3
Browse files Browse the repository at this point in the history
Release v1.16.3
  • Loading branch information
jm42 authored Aug 29, 2024
2 parents 165cd42 + a2917d1 commit 0748e58
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
15 changes: 12 additions & 3 deletions netlify/edge-functions/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default async function handler(request, context) {

let totalSupply = 0
let totalReservations = 0
let totalMoments = 0
let names = []
let ts = Math.trunc(Date.now() / 1000)

Expand All @@ -89,6 +90,7 @@ export default async function handler(request, context) {

totalSupply += eventInfo.owners?.owners.length ?? 0
totalReservations += eventInfo.metrics?.emailReservations ?? 0
totalMoments += eventInfo.metrics?.momentsUploaded ?? 0
names = [...names, eventInfo.event.name]
ts = Math.min(ts, eventInfo.owners?.ts ?? eventInfo.metrics?.ts)
}
Expand All @@ -99,9 +101,16 @@ export default async function handler(request, context) {
html,
escapeHtml(names.join(', ')),
escapeHtml(
totalReservations > 0
? `[ ${totalSupply} + ${totalReservations} ]`
: `[ ${totalSupply} ]`
[
totalReservations > 0
? `[ ${totalSupply} + ${totalReservations} ]`
: `[ ${totalSupply} ]`,
...(
totalMoments > 0
? [`[ ${totalMoments} moment${totalMoments === 1 ? '' : 's'} ]`]
: []
),
].join(' ')
),
`${env.FAMILY_URL}/images/${eventIds.join(',')}`,
`${env.FAMILY_URL}/events/${eventIds.join(',')}${queryString}`
Expand Down
19 changes: 16 additions & 3 deletions netlify/utils/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,23 @@ export function encodeEvent(eventInfo) {
export function encodeMetrics(eventInfo) {
const supply = eventInfo.owners?.length ?? 0
const reservations = eventInfo.metrics?.emailReservations ?? 0
const moments = eventInfo.metrics?.momentsUploaded ?? 0

return reservations > 0
? `[ ${supply} + ${reservations} ]`
: `[ ${supply} ]`
const metrics = [];

metrics.push(
reservations > 0
? `[ ${supply} + ${reservations} ]`
: `[ ${supply} ]`
)

if (moments > 0) {
metrics.push(
`[ ${moments} moment${moments === 1 ? '' : 's'} ]`
)
}

return metrics.join(' ')
}

export function encodeLocation(event) {
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.16.2",
"version": "1.16.3",
"author": {
"name": "POAP",
"url": "https://poap.xyz"
Expand Down

0 comments on commit 0748e58

Please sign in to comment.