Skip to content

Commit

Permalink
Merge pull request #206 from poap-xyz/release/v1.12.4
Browse files Browse the repository at this point in the history
Release v1.12.4
  • Loading branch information
jm42 authored Apr 28, 2024
2 parents 624b9b3 + a28dcfe commit 379bc82
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
29 changes: 25 additions & 4 deletions netlify/components/Stats.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React from 'https://esm.sh/react'
import { ShadowText } from './ShadowText.jsx'

export function Stats({ supply, reservations, moments, collections }) {
export function Stats({
supply,
reservations,
collectors,
drops,
moments,
collections,
}) {
const total = supply + reservations

const highlighted = {
Expand All @@ -18,18 +25,32 @@ export function Stats({ supply, reservations, moments, collections }) {
})
stats.push({
text: String(reservations),
title: `reservation${reservations === 1 ? '' : 's'}`,
title: `email collector${reservations === 1 ? '' : 's'}`,
})
}

if (moments && moments > 0) {
if (collectors != null && collectors > 0) {
stats.push({
text: String(collectors),
title: `complete collector${collectors === 1 ? '' : 's'}`,
})
}

if (drops != null && drops > 1) {
stats.push({
text: String(drops),
title: 'drops',
})
}

if (moments != null && moments > 0) {
stats.push({
text: String(moments),
title: `moment${moments === 1 ? '' : 's'}`,
})
}

if (collections && collections > 0) {
if (collections != null && collections > 0) {
stats.push({
text: String(collections),
title: `collection${collections === 1 ? '' : 's'}`,
Expand Down
9 changes: 9 additions & 0 deletions netlify/edge-functions/frame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { parseEventIds, sortEvents } from '../utils/event.js'
import { renderEventsImages } from '../utils/image.js'
import { EventHeader } from '../components/EventHeader.jsx'
import { Stats } from '../components/Stats.jsx'
import { intersection } from '../../src/utils/array.js'

function parseRequestUrl(requestUrl) {
const url = new URL(requestUrl)
Expand Down Expand Up @@ -36,11 +37,15 @@ export default async function handler(request, context) {
const eventsInfo = sortEvents(eventMap)
const images = []

let allCollectors = null
let totalSupply = 0
let totalReservations = 0
let totalMoments = 0

for (const eventInfo of eventsInfo) {
allCollectors = allCollectors == null
? eventInfo.owners
: intersection(allCollectors, eventInfo.owners)
totalSupply += eventInfo.owners.length
totalReservations += eventInfo.metrics?.emailReservations ?? 0
totalMoments += eventInfo.metrics?.momentsUploaded ?? 0
Expand Down Expand Up @@ -136,6 +141,10 @@ export default async function handler(request, context) {
{Stats({
supply: totalSupply,
reservations: totalReservations,
drops: eventIds.length,
collectors: eventIds.length === 1 || allCollectors == null
? null
: allCollectors.length,
moments: totalMoments,
collections: eventsInfo.length === 1 ? eventsInfo[0].metrics?.collectionsIncludes ?? 0 : 0,
})}
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.3",
"version": "1.12.4",
"author": {
"name": "POAP",
"url": "https://poap.xyz"
Expand Down

0 comments on commit 379bc82

Please sign in to comment.