Skip to content

Commit 2c534cb

Browse files
committed
fix: update meetup query and parsing to match new structure
1 parent 88a1c43 commit 2c534cb

4 files changed

Lines changed: 47 additions & 26 deletions

File tree

pkg/importer/meetup_repository.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ func NewGraphQLMeetupRepository(
4040

4141
const getFutureEventsQuery = `
4242
query ($urlname: String!, $itemsNum: Int!, $cursor: String) {
43-
events: groupByUrlname(urlname: $urlname) {
44-
unifiedEvents(input: { first: $itemsNum, after: $cursor }) {
45-
count
43+
groupByUrlname(urlname: $urlname) {
44+
events(first: $itemsNum, after: $cursor, filter: { status: [ACTIVE] }) {
45+
totalCount
4646
pageInfo {
4747
endCursor
4848
hasNextPage
@@ -66,12 +66,12 @@ const getFutureEventsQuery = `
6666
name
6767
urlname
6868
}
69-
host {
69+
eventHosts {
7070
name
7171
}
72-
images {
72+
featuredEventPhoto {
73+
id
7374
baseUrl
74-
preview
7575
}
7676
}
7777
}
@@ -82,16 +82,16 @@ const getFutureEventsQuery = `
8282

8383
type MeetupFutureEventsResponse struct {
8484
Data struct {
85-
Events struct {
86-
UnifiedEvents struct {
87-
Count int `json:"count"`
88-
PageInfo struct {
85+
GroupByUrlname struct {
86+
Events struct {
87+
TotalCount int `json:"totalCount"`
88+
PageInfo struct {
8989
EndCursor string `json:"endCursor"`
9090
HasNextPage bool `json:"hasNextPage"`
9191
} `json:"pageInfo"`
9292
Edges []MeetupEdge `json:"edges"`
93-
} `json:"unifiedEvents"`
94-
} `json:"events"`
93+
} `json:"events"`
94+
} `json:"groupByUrlname"`
9595
} `json:"data"`
9696
}
9797

@@ -128,7 +128,7 @@ func (r *GraphQLMeetupRepository) GetEventsUntilDateForGroup(
128128
return nil, err
129129
}
130130

131-
for _, edge := range response.Data.Events.UnifiedEvents.Edges {
131+
for _, edge := range response.Data.GroupByUrlname.Events.Edges {
132132
event := edge.Node
133133
events = append(events, event)
134134

@@ -141,7 +141,7 @@ func (r *GraphQLMeetupRepository) GetEventsUntilDateForGroup(
141141
break
142142
}
143143

144-
pageInfo := response.Data.Events.UnifiedEvents.PageInfo
144+
pageInfo := response.Data.GroupByUrlname.Events.PageInfo
145145

146146
if !pageInfo.HasNextPage {
147147
break

pkg/importer/meetup_repository_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ func generateMeetupResponse(
136136
cursor string,
137137
) *MeetupFutureEventsResponse {
138138
response := &MeetupFutureEventsResponse{}
139-
response.Data.Events.UnifiedEvents.Count = len(events)
140-
response.Data.Events.UnifiedEvents.PageInfo.EndCursor = cursor
141-
response.Data.Events.UnifiedEvents.PageInfo.HasNextPage = cursor != ""
139+
response.Data.GroupByUrlname.Events.TotalCount = len(events)
140+
response.Data.GroupByUrlname.Events.PageInfo.EndCursor = cursor
141+
response.Data.GroupByUrlname.Events.PageInfo.HasNextPage = cursor != ""
142142

143143
edges := make([]MeetupEdge, 0, len(events))
144144

145145
for _, event := range events {
146146
edges = append(edges, MeetupEdge{Node: event})
147147
}
148148

149-
response.Data.Events.UnifiedEvents.Edges = edges
149+
response.Data.GroupByUrlname.Events.Edges = edges
150150
return response
151151
}

pkg/shared/models/meetup.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ func (e *MeetupEvent) UnmarshalJSON(data []byte) error {
4141
Name string `json:"name"`
4242
URLName string `json:"urlname"`
4343
} `json:"group"`
44+
EventHosts []struct {
45+
Name string `json:"name"`
46+
} `json:"eventHosts"`
47+
FeaturedPhoto *struct {
48+
ID string `json:"id"`
49+
BaseUrl string `json:"baseUrl"`
50+
} `json:"featuredEventPhoto"`
4451
*Alias
4552
}{
4653
Alias: (*Alias)(e),
@@ -52,5 +59,19 @@ func (e *MeetupEvent) UnmarshalJSON(data []byte) error {
5259

5360
e.GroupName = aux.Group.Name
5461
e.GroupID = aux.Group.URLName
62+
63+
// Extract first event host name for backward compatibility
64+
if len(aux.EventHosts) > 0 && aux.EventHosts[0].Name != "" {
65+
e.Host = &MeetupHost{Name: aux.EventHosts[0].Name}
66+
}
67+
68+
// Map featuredEventPhoto to Images for backward compatibility
69+
if aux.FeaturedPhoto != nil && aux.FeaturedPhoto.ID != "" {
70+
imageURL := aux.FeaturedPhoto.BaseUrl + aux.FeaturedPhoto.ID + "/676x380.jpg"
71+
e.Images = []MeetupImage{
72+
{BaseUrl: imageURL, Preview: imageURL},
73+
}
74+
}
75+
5576
return nil
5677
}

pkg/shared/models/meetup_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ func TestMeetupEvent_UnmarshalJSON(t *testing.T) {
2828
"name": "Open SGF",
2929
"urlname": "open-sgf"
3030
},
31-
"host": {
32-
"name": "Levi Zitting"
33-
},
34-
"images": [
31+
"eventHosts": [
3532
{
36-
"baseUrl": "https://secure-content.meetupstatic.com/images/classic-events/",
37-
"preview": null
33+
"name": "Levi Zitting"
3834
}
39-
]
35+
],
36+
"featuredEventPhoto": {
37+
"id": "501234567",
38+
"baseUrl": "https://secure-content.meetupstatic.com/images/classic-events/"
39+
}
4040
}`
4141

4242
var event MeetupEvent
@@ -60,7 +60,7 @@ func TestMeetupEvent_UnmarshalJSON(t *testing.T) {
6060
assert.Len(t, event.Images, 1)
6161
assert.Equal(
6262
t,
63-
"https://secure-content.meetupstatic.com/images/classic-events/",
63+
"https://secure-content.meetupstatic.com/images/classic-events/501234567/676x380.jpg",
6464
event.Images[0].BaseUrl,
6565
)
6666
}

0 commit comments

Comments
 (0)