@@ -12,9 +12,18 @@ import "dotenv/config"
12
12
const communityEvents = localEvents as CommunityConference [ ]
13
13
14
14
console . log ( "Community Events Import.." )
15
- const ethereumEvents = await EthereumEventsImport ( )
15
+ const year = new Date ( ) . getFullYear ( )
16
+ const ethereumEvents = await EthereumEventsImport ( year )
16
17
// Can add multiple event sources here in the future
17
18
19
+ // Try to fetch next year too, if page available
20
+ try {
21
+ const eventsNextYear = await EthereumEventsImport ( year + 1 )
22
+ ethereumEvents . push ( ...eventsNextYear )
23
+ } catch ( error : unknown ) {
24
+ console . error ( ( error as Error ) . message )
25
+ }
26
+
18
27
ethereumEvents . forEach ( ( imported ) => {
19
28
const id = communityEvents . findIndex ( ( local ) =>
20
29
tryMatchEvent ( imported , local )
@@ -39,15 +48,21 @@ function tryMatchEvent(
39
48
imported : CommunityConference ,
40
49
local : CommunityConference
41
50
) {
42
- if ( imported . title . toLocaleLowerCase ( ) === local . title . toLocaleLowerCase ( ) )
51
+ if (
52
+ imported . title . toLocaleLowerCase ( ) === local . title . toLocaleLowerCase ( ) &&
53
+ local . startDate === imported . startDate &&
54
+ local . endDate === imported . endDate
55
+ )
43
56
return true
44
57
45
58
if (
46
59
URL . canParse ( imported . href ) &&
47
60
URL . canParse ( local . href ) &&
48
61
new URL ( imported . href ) . hostname . replace ( "www." , "" ) ===
49
62
new URL ( local . href ) . hostname . replace ( "www." , "" ) &&
50
- new URL ( imported . href ) . pathname === new URL ( local . href ) . pathname
63
+ new URL ( imported . href ) . pathname === new URL ( local . href ) . pathname &&
64
+ local . startDate === imported . startDate &&
65
+ local . endDate === imported . endDate
51
66
) {
52
67
return true
53
68
}
0 commit comments