Skip to content

Commit

Permalink
#13: removed some devoxx conf description json entries, replaced by A…
Browse files Browse the repository at this point in the history
…PI data (floor plans, venue coordinates)
  • Loading branch information
fcamblor committed Oct 10, 2023
1 parent 8747341 commit 2922f9c
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions cloud/functions/src/crawlers/devoxx/crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,30 @@ export const DEVOXX_DESCRIPTOR_PARSER = EVENT_DESCRIPTOR_PARSER.omit({
eventFamily: z.string(),
infos: INFOS_PARSER.extend({
address: z.string().nullish(),
coords: z.object({ latitude: z.number(), longitude: z.number() }).nullish(),
})
}).omit({ plans: true })
})

type DevoxxFloorPlan = {
id: number,
name: string,
imageURL: string,
}

export const DEVOXX_CRAWLER: CrawlerKind<typeof DEVOXX_DESCRIPTOR_PARSER> = {
kind: 'devoxx',
descriptorParser: DEVOXX_DESCRIPTOR_PARSER,
crawlerImpl: async (eventId: string, descriptor: z.infer<typeof DEVOXX_DESCRIPTOR_PARSER>, criteria: { dayIds?: string[]|undefined }) => {
const cfpBaseUrl = descriptor.cfpBaseUrl || `https://${descriptor.cfpId}.cfp.dev`;
const res = await axios.get(`${cfpBaseUrl+(cfpBaseUrl.endsWith("/")?"":"/")}api/public/event`)
const e: CfpEvent = res.data;
const rawCfpBaseUrl = descriptor.cfpBaseUrl || `https://${descriptor.cfpId}.cfp.dev`;
const cfpBaseUrl = rawCfpBaseUrl+(rawCfpBaseUrl.endsWith("/")?"":"/")
const [eventResp, floorPlansResp] = await Promise.all([
axios.get(`${cfpBaseUrl}api/public/event`),
axios.get(`${cfpBaseUrl}api/public/floorplans`),
])
const cfpEvent: CfpEvent = eventResp.data;
const cfpFloorPlans: DevoxxFloorPlan[]|undefined = floorPlansResp?.data;

const start = e.fromDate.substring(0, 10) as ISOLocalDate
const end = e.toDate.substring(0, 10) as ISOLocalDate
const start = cfpEvent.fromDate.substring(0, 10) as ISOLocalDate
const end = cfpEvent.toDate.substring(0, 10) as ISOLocalDate

// collect days
const days: Day[] = []
Expand All @@ -71,20 +81,23 @@ export const DEVOXX_CRAWLER: CrawlerKind<typeof DEVOXX_DESCRIPTOR_PARSER> = {
const eventInfo = {
id: eventId,
eventFamily: descriptor.eventFamily || 'devoxx',
title: e.name,
description: e.description,
title: cfpEvent.name,
description: cfpEvent.description,
peopleDescription: descriptor.peopleDescription,
timezone: e.timezone,
timezone: cfpEvent.timezone,
start: start,
end: end,
days: days,
logoUrl: descriptor.logoUrl,
backgroundUrl: descriptor.backgroundUrl,
websiteUrl: e.website,
websiteUrl: cfpEvent.website,
location: {
city: e.locationCity, country: e.locationCountry,
city: cfpEvent.locationCity, country: cfpEvent.locationCountry,
coords: {
latitude: cfpEvent.venueLatitude,
longitude: cfpEvent.venueLongitude
},
...(descriptor.infos.address ? {address: descriptor.infos.address} : {}),
...(descriptor.infos.coords ? {coords: descriptor.infos.coords} : {}),
},
theming: descriptor.theming,
keywords: descriptor.keywords
Expand Down Expand Up @@ -123,6 +136,10 @@ export const DEVOXX_CRAWLER: CrawlerKind<typeof DEVOXX_DESCRIPTOR_PARSER> = {
infos: {
eventDescription: descriptor.infos.eventDescription,
venuePicture: descriptor.infos.venuePicture,
plans: (cfpFloorPlans || []).map(cfpFloorPlan => ({
title: cfpFloorPlan.name,
pictureUrl: cfpFloorPlan.imageURL
}))
},
...(descriptor.socialMedias ? {socialMedias: descriptor.socialMedias} : {}),
...(descriptor.sponsors ? {sponsors: descriptor.sponsors} : {}),
Expand All @@ -138,7 +155,7 @@ export const DEVOXX_CRAWLER: CrawlerKind<typeof DEVOXX_DESCRIPTOR_PARSER> = {


const crawlDevoxxDay = async (cfpBaseUrl: string, day: string) => {
const res = await axios.get(`${cfpBaseUrl+(cfpBaseUrl.endsWith("/")?"":"/")}api/public/schedules/${day}`)
const res = await axios.get(`${cfpBaseUrl}api/public/schedules/${day}`)

const schedules:DevoxxScheduleItem[] = res.data;

Expand Down

0 comments on commit 2922f9c

Please sign in to comment.