-
-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Events attended support added with fetching recurring event query #2551
base: develop
Are you sure you want to change the base?
Changes from all commits
3bc9ece
07e2450
8f9f6ec
dcc3866
2d9adca
12992ee
5978b13
f366dee
1d65fe0
6597863
9bace40
02f4632
a96ef24
693f686
9637068
e109418
e770916
440d651
50c6c10
7bfad44
30fbe61
3ad2e4e
87b6ffe
83996d4
f820db1
b6ca09e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { QueryResolvers } from "../../types/generatedGraphQLTypes"; | ||
import { Event } from "../../models"; | ||
import { getSort } from "./helperFunctions/getSort"; | ||
|
||
/** | ||
* This query will fetch all the events for which user attended from the database. | ||
* @param _parent- | ||
* @param args - An object that contains `id` of the user and `orderBy`. | ||
* @returns An object that contains the Event data. | ||
* @remarks The query function uses `getSort()` function to sort the data in specified. | ||
*/ | ||
export const eventsAttendedByUser: QueryResolvers["eventsAttendedByUser"] = | ||
async (_parent, args) => { | ||
const sort = getSort(args.orderBy); | ||
|
||
return await Event.find({ | ||
registrants: { | ||
$elemMatch: { | ||
userId: args.id, | ||
status: "ACTIVE", | ||
}, | ||
}, | ||
}) | ||
.sort(sort) | ||
.populate("creatorId", "-password") | ||
.populate("admins", "-password") | ||
.lean(); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { QueryResolvers } from "../../types/generatedGraphQLTypes"; | ||
import { Event } from "../../models"; | ||
import type { InterfaceEvent } from "../../models/Event"; | ||
/** | ||
* This query will fetch all the events with the same BaseRecurringEventId from the database. | ||
* @param _parent - | ||
* @param args - An object that contains `baseRecurringEventId` of the base recurring event. | ||
* @returns An array of `Event` objects that are instances of the base recurring event. | ||
*/ | ||
|
||
export const getRecurringEvents: QueryResolvers["getRecurringEvents"] = async ( | ||
_parent, | ||
args, | ||
) => { | ||
try { | ||
const recurringEvents = await Event.find({ | ||
baseRecurringEventId: args.baseRecurringEventId, | ||
}).lean(); | ||
|
||
return recurringEvents as InterfaceEvent[]; | ||
} catch (error) { | ||
console.error("Error fetching recurring events:", error); | ||
throw error; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2295,6 +2295,7 @@ export type Query = { | |||||||||||||||||
directChatsMessagesByChatID?: Maybe<Array<Maybe<DirectChatMessage>>>; | ||||||||||||||||||
event?: Maybe<Event>; | ||||||||||||||||||
eventVolunteersByEvent?: Maybe<Array<Maybe<EventVolunteer>>>; | ||||||||||||||||||
eventsAttendedByUser?: Maybe<Array<Maybe<Event>>>; | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Missing Field to Query Type The Apply this diff to include the new field: export type Query = {
__typename?: 'Query';
actionItemCategoriesByOrganization?: Maybe<Array<Maybe<ActionItemCategory>>>;
actionItemsByEvent?: Maybe<Array<Maybe<ActionItem>>>;
actionItemsByOrganization?: Maybe<Array<Maybe<ActionItem>>>;
adminPlugin?: Maybe<Array<Maybe<Plugin>>>;
advertisementsConnection?: Maybe<AdvertisementsConnection>;
agendaCategory: AgendaCategory;
agendaItemByEvent?: Maybe<Array<Maybe<AgendaItem>>>;
agendaItemByOrganization?: Maybe<Array<Maybe<AgendaItem>>>;
agendaItemCategoriesByOrganization?: Maybe<Array<Maybe<AgendaCategory>>>;
checkAuth: User;
customDataByOrganization: Array<UserCustomData>;
customFieldsByOrganization?: Maybe<Array<Maybe<OrganizationCustomField>>>;
directChatById?: Maybe<DirectChat>;
directChatsByUserID?: Maybe<Array<Maybe<DirectChat>>>;
directChatsMessagesByChatID?: Maybe<Array<Maybe<DirectChatMessage>>>;
event?: Maybe<Event>;
eventVolunteersByEvent?: Maybe<Array<Maybe<EventVolunteer>>>;
+ eventsAttendedByUser?: Maybe<Array<Maybe<Event>>>;
eventsByOrganization?: Maybe<Array<Maybe<Event>>>;
eventsByOrganizationConnection: Array<Event>;
fundsByOrganization?: Maybe<Array<Maybe<Fund>>>;
// ... other existing fields
};
|
||||||||||||||||||
eventsByOrganization?: Maybe<Array<Maybe<Event>>>; | ||||||||||||||||||
eventsByOrganizationConnection: Array<Event>; | ||||||||||||||||||
fundsByOrganization?: Maybe<Array<Maybe<Fund>>>; | ||||||||||||||||||
|
@@ -2316,6 +2317,7 @@ export type Query = { | |||||||||||||||||
getNoteById: Note; | ||||||||||||||||||
getPledgesByUserId?: Maybe<Array<Maybe<FundraisingCampaignPledge>>>; | ||||||||||||||||||
getPlugins?: Maybe<Array<Maybe<Plugin>>>; | ||||||||||||||||||
getRecurringEvents?: Maybe<Array<Maybe<Event>>>; | ||||||||||||||||||
getUserTag?: Maybe<UserTag>; | ||||||||||||||||||
getUserTagAncestors?: Maybe<Array<Maybe<UserTag>>>; | ||||||||||||||||||
getVenueByOrgId?: Maybe<Array<Maybe<Venue>>>; | ||||||||||||||||||
|
@@ -2430,6 +2432,12 @@ export type QueryEventVolunteersByEventArgs = { | |||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
export type QueryEventsAttendedByUserArgs = { | ||||||||||||||||||
id?: InputMaybe<Scalars['ID']['input']>; | ||||||||||||||||||
orderBy?: InputMaybe<EventOrderByInput>; | ||||||||||||||||||
}; | ||||||||||||||||||
Comment on lines
+2435
to
+2438
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Clarify Argument Naming for User ID The argument Apply the following diff to update the argument name: -export type QueryEventsAttendedByUserArgs = {
- id?: InputMaybe<Scalars['ID']['input']>;
+ userId?: InputMaybe<Scalars['ID']['input']>;
orderBy?: InputMaybe<EventOrderByInput>;
}; 📝 Committable suggestion
Suggested change
Consider Making The Apply this diff to make export type QueryEventsAttendedByUserArgs = {
- userId?: InputMaybe<Scalars['ID']['input']>;
+ userId: Scalars['ID']['input'];
orderBy?: InputMaybe<EventOrderByInput>;
}; Ensure that the resolver accounts for this change and that appropriate error messages are returned if
|
||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
export type QueryEventsByOrganizationArgs = { | ||||||||||||||||||
id?: InputMaybe<Scalars['ID']['input']>; | ||||||||||||||||||
orderBy?: InputMaybe<EventOrderByInput>; | ||||||||||||||||||
|
@@ -2536,6 +2544,11 @@ export type QueryGetPledgesByUserIdArgs = { | |||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
export type QueryGetRecurringEventsArgs = { | ||||||||||||||||||
baseRecurringEventId: Scalars['ID']['input']; | ||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
export type QueryGetUserTagArgs = { | ||||||||||||||||||
id: Scalars['ID']['input']; | ||||||||||||||||||
}; | ||||||||||||||||||
|
@@ -2950,6 +2963,7 @@ export type User = { | |||||||||||||||||
email: Scalars['EmailAddress']['output']; | ||||||||||||||||||
employmentStatus?: Maybe<EmploymentStatus>; | ||||||||||||||||||
eventAdmin?: Maybe<Array<Maybe<Event>>>; | ||||||||||||||||||
eventsAttended?: Maybe<Array<Maybe<Event>>>; | ||||||||||||||||||
firstName: Scalars['String']['output']; | ||||||||||||||||||
gender?: Maybe<Gender>; | ||||||||||||||||||
identifier: Scalars['Int']['output']; | ||||||||||||||||||
|
@@ -4610,6 +4624,7 @@ export type QueryResolvers<ContextType = any, ParentType extends ResolversParent | |||||||||||||||||
directChatsMessagesByChatID?: Resolver<Maybe<Array<Maybe<ResolversTypes['DirectChatMessage']>>>, ParentType, ContextType, RequireFields<QueryDirectChatsMessagesByChatIdArgs, 'id'>>; | ||||||||||||||||||
event?: Resolver<Maybe<ResolversTypes['Event']>, ParentType, ContextType, RequireFields<QueryEventArgs, 'id'>>; | ||||||||||||||||||
eventVolunteersByEvent?: Resolver<Maybe<Array<Maybe<ResolversTypes['EventVolunteer']>>>, ParentType, ContextType, RequireFields<QueryEventVolunteersByEventArgs, 'id'>>; | ||||||||||||||||||
eventsAttendedByUser?: Resolver<Maybe<Array<Maybe<ResolversTypes['Event']>>>, ParentType, ContextType, Partial<QueryEventsAttendedByUserArgs>>; | ||||||||||||||||||
eventsByOrganization?: Resolver<Maybe<Array<Maybe<ResolversTypes['Event']>>>, ParentType, ContextType, Partial<QueryEventsByOrganizationArgs>>; | ||||||||||||||||||
eventsByOrganizationConnection?: Resolver<Array<ResolversTypes['Event']>, ParentType, ContextType, Partial<QueryEventsByOrganizationConnectionArgs>>; | ||||||||||||||||||
fundsByOrganization?: Resolver<Maybe<Array<Maybe<ResolversTypes['Fund']>>>, ParentType, ContextType, RequireFields<QueryFundsByOrganizationArgs, 'organizationId'>>; | ||||||||||||||||||
|
@@ -4631,6 +4646,7 @@ export type QueryResolvers<ContextType = any, ParentType extends ResolversParent | |||||||||||||||||
getNoteById?: Resolver<ResolversTypes['Note'], ParentType, ContextType, RequireFields<QueryGetNoteByIdArgs, 'id'>>; | ||||||||||||||||||
getPledgesByUserId?: Resolver<Maybe<Array<Maybe<ResolversTypes['FundraisingCampaignPledge']>>>, ParentType, ContextType, RequireFields<QueryGetPledgesByUserIdArgs, 'userId'>>; | ||||||||||||||||||
getPlugins?: Resolver<Maybe<Array<Maybe<ResolversTypes['Plugin']>>>, ParentType, ContextType>; | ||||||||||||||||||
getRecurringEvents?: Resolver<Maybe<Array<Maybe<ResolversTypes['Event']>>>, ParentType, ContextType, RequireFields<QueryGetRecurringEventsArgs, 'baseRecurringEventId'>>; | ||||||||||||||||||
getUserTag?: Resolver<Maybe<ResolversTypes['UserTag']>, ParentType, ContextType, RequireFields<QueryGetUserTagArgs, 'id'>>; | ||||||||||||||||||
getUserTagAncestors?: Resolver<Maybe<Array<Maybe<ResolversTypes['UserTag']>>>, ParentType, ContextType, RequireFields<QueryGetUserTagAncestorsArgs, 'id'>>; | ||||||||||||||||||
getVenueByOrgId?: Resolver<Maybe<Array<Maybe<ResolversTypes['Venue']>>>, ParentType, ContextType, RequireFields<QueryGetVenueByOrgIdArgs, 'orgId'>>; | ||||||||||||||||||
|
@@ -4735,6 +4751,7 @@ export type UserResolvers<ContextType = any, ParentType extends ResolversParentT | |||||||||||||||||
email?: Resolver<ResolversTypes['EmailAddress'], ParentType, ContextType>; | ||||||||||||||||||
employmentStatus?: Resolver<Maybe<ResolversTypes['EmploymentStatus']>, ParentType, ContextType>; | ||||||||||||||||||
eventAdmin?: Resolver<Maybe<Array<Maybe<ResolversTypes['Event']>>>, ParentType, ContextType>; | ||||||||||||||||||
eventsAttended?: Resolver<Maybe<Array<Maybe<ResolversTypes['Event']>>>, ParentType, ContextType>; | ||||||||||||||||||
firstName?: Resolver<ResolversTypes['String'], ParentType, ContextType>; | ||||||||||||||||||
gender?: Resolver<Maybe<ResolversTypes['Gender']>, ParentType, ContextType>; | ||||||||||||||||||
identifier?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Missing Removed or Replaced Code in
schema.graphql
The
schema.graphql
file includes the neweventsAttended: [Event]
field but does not show any removed or replaced code as expected. Please ensure that all related modifications are properly implemented and reflected in the schema.🔗 Analysis chain
New field added to User type:
eventsAttended
The
eventsAttended
field has been added to theUser
type, returning an array ofEvent
objects. This addition is consistent with the PR objectives and complements the neweventsAttendedByUser
query.To ensure this field is properly implemented in the User model, please run the following script:
Verification Script Update Needed
The initial verification script could not locate
src/models/User.ts
. Please run the following script to find the correctUser.ts
file and verify the implementation of theeventsAttended
field:Verification of
eventsAttendedByUser
Query ImplementationTo ensure that the
eventsAttendedByUser
query properly utilizes theeventsAttended
field in theUser
model, please run the following script:Corrected Verification Script for
eventsAttendedByUser
QueryThe previous verification script encountered errors by incorrectly processing matched lines as file paths. Please run the following corrected script to accurately locate and verify the implementation of the
eventsAttendedByUser
query and its usage of theeventsAttended
field:🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 138
Script:
Length of output: 548
Script:
Length of output: 3893
Script:
Length of output: 101