Skip to content

Commit

Permalink
Update 2.3.1 (#226)
Browse files Browse the repository at this point in the history
* feat: add support to Deck2 (#219)

* fix: add company description (#220)

* feat: add sponsors site (#223)

Co-authored-by: André Romão <[email protected]>

* adds calendar to event in cannon (#224)

* improves promo codes (#225)

---------

Co-authored-by: Nuno Alves <[email protected]>
Co-authored-by: André Romão <[email protected]>
  • Loading branch information
3 people authored Apr 10, 2024
1 parent ce5a5ab commit f36ead9
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 4 deletions.
5 changes: 4 additions & 1 deletion server/db/promo-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const mongoose = require('mongoose')
const schema = new mongoose.Schema({
company: String,
edition: String,
expire: Date,
validity: {
from: Date,
to: Date
},
description: String,
code: String
})
Expand Down
2 changes: 2 additions & 0 deletions server/resources/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function transformEvent(event, options) {
public: options?.public || true,
date: event.begin,
duration: new Date(new Date(event.end) - new Date(event.begin)),
calendarUrl: event.calendarUrl
}
}

Expand All @@ -117,6 +118,7 @@ function transformCompany(company, options) {
id: company.id,
name: company.name,
img: company.img,
site: company.site,
description: company.description,
advertisementLvl: options?.compact ? advertisementLvl : {
advertisementLvl,
Expand Down
7 changes: 6 additions & 1 deletion server/resources/promo-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ server.method('promoCode.get', get, {})
async function get () {
let now = new Date()

filter = {
'validity.from': { $lte: now },
'validity.to': { $gte: now }
}

try {
let codes = await PromoCode.find({ expire: { '$gt': now.toISOString() } }, {}, {})
let codes = await PromoCode.find(filter)
if (!codes) {
log.warn({ err: err }, 'could not find promo code')
return cb(Boom.notFound())
Expand Down
16 changes: 16 additions & 0 deletions server/routes/deck/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,19 @@ exports.getSpeaker = {
}
}
}

exports.getCalendarUrl = {
options: {
tags: ['api', 'calendar'],
description: 'Get the calendar url for the current edition'
},
handler: async (request, h) => {
try {
const edition = await request.server.methods.deck.getLatestEdition()
return h.response(edition.calendarUrl)
} catch(err) {
log.error({ error: err })
throw Boom.boomify(err)
}
}
}
7 changes: 7 additions & 0 deletions server/routes/deck/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,11 @@ server.route({
path: '/speaker/{speakerId}',
options: handlers.getSpeaker.options,
handler: handlers.getSpeaker.handler
})

server.route({
method: 'GET',
path: '/calendar',
options: handlers.getCalendarUrl.options,
handler: handlers.getCalendarUrl.handler
})
1 change: 1 addition & 0 deletions server/views/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function renderObject (model) {
return {
id: model.id,
name: model.name,
site: model.site,
advertisementLvl: model.advertisementLvl,
img: model.img
}
Expand Down
3 changes: 2 additions & 1 deletion server/views/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = function render (content) {
duration: model.duration,
begin: model.begin,
end: model.end,
isOcurring: model.isOcurring
isOcurring: model.isOcurring,
calendarUrl: model.calendarUrl,
}
}

2 changes: 1 addition & 1 deletion server/views/promo-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function renderObject (model) {
return {
company: model.company,
edition: model.edition,
expire: model.expire,
expire: model.validity.to,
description: model.description,
code: model.code
}
Expand Down

0 comments on commit f36ead9

Please sign in to comment.