Skip to content

Commit e1eda69

Browse files
committed
form time inconsistency triage
1 parent eac213c commit e1eda69

9 files changed

Lines changed: 374 additions & 308 deletions

File tree

atproto-slurper/slurper/server.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,55 @@ app.get("/calendar-events", async (req, res) => {
540540
res.status(500).json({ error });
541541
} else {
542542
const formatted = data?.map((rawEvent) => {
543+
let recordPassedReview = rawEvent.record_passed_review
544+
// const devconnectFormSubmissionsDid = 'did:plc:l26dgtpir4fydulvmuoee2sn'
545+
// // @ts-ignore
546+
// const currentDid = rawEvent.atproto_dids.did
547+
548+
// const isDevconnectFormSubmission = currentDid === devconnectFormSubmissionsDid
549+
550+
// // Helper function to convert Argentina time to UTC (subtract 3 hours)
551+
// const convertArgentinaToUtc = (timestamp: string) => {
552+
// const date = new Date(timestamp);
553+
// date.setHours(date.getHours() - 3);
554+
// return date.toISOString();
555+
// }
556+
557+
// const tmpFixTimezone = (event: any) => {
558+
// // If event is from Devconnect submission form, then convert from Argentina time back to UTC time (subtract 3 hours)
559+
// // This is because the form is UTC, but people have been entering the time in Argentina time, and so this is now the de facto standard
560+
// // Had to change the form to not say UTC as well, which is unfortunate - anyway, the fix for now is to convert from Argentina time back to UTC time for events through the form - this needs to be fixed for future editions if we still use atprotocol.
561+
// let fixedEvent = event
562+
563+
// if (isDevconnectFormSubmission) {
564+
// if (event.timeblocks) {
565+
// fixedEvent.timeblocks = event.timeblocks.map((timeblock: any) => {
566+
// timeblock.start_utc = convertArgentinaToUtc(timeblock.start_utc)
567+
// timeblock.end_utc = convertArgentinaToUtc(timeblock.end_utc)
568+
// return timeblock
569+
// })
570+
// }
571+
572+
// if (fixedEvent.start_utc) {
573+
// fixedEvent.start_utc = convertArgentinaToUtc(fixedEvent.start_utc)
574+
// }
575+
// if (fixedEvent.end_utc) {
576+
// fixedEvent.end_utc = convertArgentinaToUtc(fixedEvent.end_utc)
577+
// }
578+
579+
// return fixedEvent
580+
// }
581+
582+
// return event
583+
// }
584+
585+
// // Apply timezone fix
586+
// const fixedRecord = tmpFixTimezone(recordPassedReview);
587+
543588
return {
544589
...rawEvent,
545590
record_passed_review: {
546-
...rawEvent.record_passed_review,
591+
...recordPassedReview,
547592
...rawEvent.admin_override,
548593
},
549594
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE atproto_records
2+
ADD COLUMN priority INTEGER DEFAULT 0;
3+
4+
-- Add comment for documentation
5+
COMMENT ON COLUMN atproto_records.priority IS 'Priority of the event on the calendar';

devconnect/next.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ module.exports = {
5151
'www.gravatar.com',
5252
'mealmslwugsqqyoesrxd.supabase.co',
5353
],
54+
remotePatterns: [
55+
{
56+
protocol: 'https',
57+
hostname: '*',
58+
},
59+
],
5460
},
5561
webpack: (config, { webpack, isServer }) => {
5662
const artifactPackageJsonPath = require.resolve('@pcd/proto-pod-gpc-artifacts/package.json')

devconnect/src/pages/calendar.tsx

Lines changed: 2 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
22
import { useCalendarStore } from 'store/calendar'
3-
import { Client } from '@notionhq/client'
43
import { Footer, Header, withTranslations } from 'pages/index'
54
import { client } from '../../tina/__generated__/client'
65
import { useTina } from 'tinacms/dist/react'
@@ -14,29 +13,13 @@ import RichText from 'lib/components/tina-cms/RichText'
1413
import { CMSButtons } from 'common/components/voxel-button/button'
1514
import CalendarLayout from 'lib/components/event-schedule-new/layout'
1615
import { Separator } from 'lib/components/ui/separator'
17-
import { record } from 'zod'
18-
import { makeConsoleLogger } from '@notionhq/client/build/src/logging'
16+
import { apiResultToCalendarFormat } from 'lib/components/event-schedule-new/atproto-to-calendar-format'
1917

2018
const Argentina = (props: any) => {
2119
const { selectedEvent, selectedDay, setSelectedEvent, setSelectedDay } = useCalendarStore()
2220
const { data }: { data: any } = useTina(props.content)
2321

2422
const events = props.events
25-
// const events = props.events.map((event: any) => {
26-
// const overrides = {} as any
27-
28-
// if (event.id === '1f5638cd-c415-809b-8fbd-ec8c4ba7f5b9') {
29-
// overrides.name = 'ETH Day'
30-
// overrides.isFairEvent = true
31-
// overrides.spanRows = 3
32-
// }
33-
34-
// return {
35-
// ...event,
36-
// ...overrides,
37-
// onClick: () => {},
38-
// }
39-
// })
4023

4124
return (
4225
<>
@@ -82,41 +65,11 @@ const Argentina = (props: any) => {
8265
/>
8366

8467
<div className="section mb-8 mt-12">
85-
{/* <div className="text-center text-lg">
86-
Stay tuned for details on how to submit your event to the calendar - we will be accepting submissions very
87-
soon!
88-
</div> */}
8968
<div className="grid grid-cols-1 md:grid-cols-2 gap-12 my-4 bg-[rgba(116,172,223,0.1)] p-4 md:p-12">
9069
<RichText content={data.pages.calendar_how_to_apply} Buttons={CMSButtons} />
9170
<RichText content={data.pages.calendar_community_calendar} Buttons={CMSButtons} />
9271
</div>
9372
</div>
94-
95-
{/* <div className="text-sm flex flex-col gap-4">
96-
<p>
97-
<strong>Disclaimer:</strong> This calendar is a work in progress and may change a lot before Devconnect
98-
week. Please check back regularly for updates.
99-
</p>
100-
<div>
101-
<p>
102-
<strong>Want to be featured on our calendar?</strong> We encourage event hosts to submit their events to
103-
atprotocol adhering to the [devcon.org event record type].{' '}
104-
<strong>This is not a guarantee of inclusion as we still curate events,</strong> but is a{' '}
105-
<strong>requirement</strong> for community events to be considered on our calendar.
106-
</p>
107-
<p>
108-
<strong>How do I submit my event to atprotocol?</strong> ...
109-
</p>
110-
</div>
111-
<p>
112-
<strong>Want to build a community calendar? </strong> For your convenience, we collect all events submitted
113-
to atprotocol and expose them via{' '}
114-
<Link indicateExternal className="bold" href="https://at-slurper.onrender.com/all-events">
115-
https://at-slurper.onrender.com/all-events
116-
</Link>
117-
. You can also use atprotocol directly, as all data is public.
118-
</p>
119-
</div> */}
12073
</div>
12174

12275
<Footer />
@@ -130,165 +83,14 @@ export async function getStaticProps({ locale }: { locale: string }) {
13083
const translationPath = locale === 'en' ? 'global.json' : locale + '/global.json'
13184
const translations = await client.queries.global_translations({ relativePath: translationPath })
13285

133-
//www.notion.so/ef-events/1f5638cdc41580be9117f4963f021d8b?v=1f5638cdc415816c9277000ccc6cda85&pvs=4
134-
135-
const notion = new Client({
136-
auth: process.env.NOTION_SECRET,
137-
})
138-
139-
const query = {
140-
database_id: '1f5638cdc41580be9117f4963f021d8b',
141-
sorts: [
142-
{
143-
property: 'Requested event date',
144-
direction: 'ascending',
145-
},
146-
// {
147-
// property: '[WEB] Priority (sort)',
148-
// direction: 'descending',
149-
// },
150-
],
151-
filter: {
152-
and: [
153-
{
154-
property: 'Requested event date',
155-
date: {
156-
is_not_empty: true,
157-
},
158-
},
159-
{
160-
property: 'Live in Website',
161-
checkbox: {
162-
equals: true,
163-
},
164-
},
165-
],
166-
},
167-
}
168-
169-
let notionEvents: any = { results: [] }
170-
171-
try {
172-
notionEvents = await notion.databases.query(query as any)
173-
} catch (error) {
174-
console.error('Failed to fetch events from Notion:', error)
175-
// Continue with empty events array if Notion API fails
176-
}
177-
178-
/*
179-
export interface Event {
180-
id: string;
181-
name: string;
182-
isFairEvent?: boolean;
183-
isCoreEvent?: boolean;
184-
description: string;
185-
organizer: string;
186-
difficulty: string;
187-
amountPeople?: string;
188-
location: {
189-
url: string;
190-
text: string;
191-
coordinates?: {
192-
lat: number;
193-
lng: number;
194-
};
195-
};
196-
timeblocks: {
197-
start: string;
198-
end: string;
199-
name?: string;
200-
location?: string;
201-
}[];
202-
priority: number;
203-
categories: string[];
204-
}
205-
206-
*/
207-
208-
// console.log(notionEvents)
209-
21086
const atprotoEvents = await fetch(
21187
process.env.NODE_ENV === 'development'
21288
? 'http://localhost:4000/calendar-events'
21389
: 'https://at-slurper.onrender.com/calendar-events'
21490
)
21591
const atprotoEventsData = await atprotoEvents.json()
216-
// console.log(atprotoEventsData)
217-
218-
const formattedAtprotoEvents = atprotoEventsData.map((event: any) => {
219-
const record = event.record_passed_review
220-
221-
const timeblocks = []
222-
223-
if (record.start_utc) {
224-
let startDate = moment.utc(record.start_utc)
225-
let endDate
226-
227-
if (record.end_utc) {
228-
endDate = moment.utc(record.end_utc).format('YYYY-MM-DDTHH:mm:ss[Z]')
229-
} else {
230-
endDate = startDate.format('YYYY-MM-DDTHH:mm:ss[Z]')
231-
}
232-
233-
timeblocks.push({
234-
start: startDate.format('YYYY-MM-DDTHH:mm:ss[Z]'),
235-
end: endDate,
236-
})
237-
}
238-
239-
const manualOverrides = {} as any
240-
241-
return {
242-
id: event.id,
243-
name: record.title,
244-
description: record.description,
245-
startDate: record.start_utc,
246-
endDate: record.end_utc,
247-
location: record.location.name,
248-
difficulty: record.expertise,
249-
organizer: record.organizer.name,
250-
timeblocks: timeblocks,
251-
eventType: record.event_type,
252-
isCoreEvent: event.is_core_event || false,
253-
eventLink: record.main_url,
254-
...manualOverrides,
255-
}
256-
})
257-
258-
// const events = notionEvents.results.map((event: any) => {
259-
// const formattedEvent = formatResult(event)
260-
261-
// const timeblocks = []
262-
263-
// if (formattedEvent['Requested event date']) {
264-
// let startDate = moment.utc(formattedEvent['Requested event date'].startDate)
265-
// let endDate
266-
267-
// if (formattedEvent['Requested event date'].endDate) {
268-
// endDate = moment.utc(formattedEvent['Requested event date'].endDate).format('YYYY-MM-DDTHH:mm:ss[Z]')
269-
// } else {
270-
// endDate = startDate.format('YYYY-MM-DDTHH:mm:ss[Z]')
271-
// }
272-
273-
// timeblocks.push({
274-
// start: startDate.format('YYYY-MM-DDTHH:mm:ss[Z]'),
275-
// end: endDate,
276-
// })
277-
// }
27892

279-
// return {
280-
// id: event.id,
281-
// name: formattedEvent['Event name'] || '',
282-
// description: formattedEvent['Description'] || '',
283-
// capacity: formattedEvent['Capacity'] || '',
284-
// startDate: formattedEvent['Requested event date'],
285-
// // size: formattedEvent['Size'],
286-
// location: formattedEvent['Location'] || { text: 'TBD', url: '' },
287-
// timeblocks: timeblocks,
288-
// difficulty: 'Beginner',
289-
// organizer: formattedEvent['Organization'] || '',
290-
// }
291-
// })
93+
const formattedAtprotoEvents = apiResultToCalendarFormat(atprotoEventsData)
29294

29395
return {
29496
props: {

0 commit comments

Comments
 (0)