Skip to content

Instantly share code, notes, and snippets.

View EcZachly's full-sized avatar
🎯
Focusing

Zach Wilson EcZachly

🎯
Focusing
View GitHub Profile
@EcZachly
EcZachly / groups.sql
Created November 6, 2023 21:11
How to write an algorithm to group people in optimized groups based on timezone and track
-- first query all the users
WITH offsets AS (SELECT a.*,
EXTRACT(hour FROM ptn.utc_offset) AS utc_offset
FROM bootcamp.attendees a
JOIN pg_timezone_names ptn ON a.timezone = ptn.name
WHERE a.bootcamp_version = 3
AND a.timezone IS NOT NULL
AND a.content_delivery = 'Live'::text
),
-- then aggregate the users by track and offset, we want matching timezones to fill up first
app.get '/Cards/adv/search', (req, res) ->
console.log(req.query)
colors1 = req.query.colors
if(colors1 == undefined)
colors1 = ["White", "Blue","Black","Green", "Red"]
if(colors1.length == 0)
colors1 = ["White", "Blue","Black","Green", "Red"]
rarity1 = req.query.rares
if(rarity1 == undefined)
rarity1 = ['Common','Uncommon','Rare', 'Mythic Rare']