Skip to content
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

Add support for Volunteer Leaderboard, linking Volunteer/Groups/Membership & Integrated with Action Items #2615

Merged
merged 26 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
abed7ea
restructure eventVolunteer & volunteerGroup Models
GlenDsza Oct 5, 2024
54a1128
Support for Volunteer Membership
GlenDsza Oct 19, 2024
c00646d
Add mark action item and add hours volunteered
GlenDsza Oct 19, 2024
b3cd516
Merge branch 'develop' of https://github.com/GlenDsza/talawa-api into…
GlenDsza Oct 19, 2024
8909698
fix testcases 75
GlenDsza Oct 19, 2024
847598f
Add support for Volunteer leaderboard
GlenDsza Oct 25, 2024
562006b
Merge branch 'develop' of https://github.com/GlenDsza/talawa-api into…
GlenDsza Oct 25, 2024
4652e41
Add tests for query resolvers 100
GlenDsza Oct 27, 2024
19bbbb9
Add tests for checks
GlenDsza Oct 27, 2024
2f2f45d
Fix lints issues & add tests for helper funcs
GlenDsza Oct 27, 2024
844b10e
Fix failing tests for removeOrganization & updateEventVolunteerGroup
GlenDsza Oct 27, 2024
415877c
fix failing test for actionItem
GlenDsza Oct 27, 2024
8a38c07
Add test coverage
GlenDsza Oct 27, 2024
6abbe87
Add test coverage for updateActionItem
GlenDsza Oct 27, 2024
493977c
coderabbit suggesstions
GlenDsza Oct 27, 2024
eceffc2
remove session changes
GlenDsza Oct 27, 2024
bb76968
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
GlenDsza Oct 27, 2024
ee54d23
add support for filtering upcoming events & getVolunteerMembership re…
GlenDsza Nov 1, 2024
f914093
Merge branch 'develop' of https://github.com/GlenDsza/talawa-api into…
GlenDsza Nov 1, 2024
2bdeb0b
codeRabbit suggestions
GlenDsza Nov 1, 2024
028d2dd
Add inputs.ts in countlint exclusion
GlenDsza Nov 1, 2024
b3b5100
change allotedHours to allottedHours
GlenDsza Nov 1, 2024
55c48b5
coderabbit suggestions
GlenDsza Nov 2, 2024
d35ee3b
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
GlenDsza Nov 2, 2024
f634d1b
coderabbit suggestion
GlenDsza Nov 2, 2024
b41d77e
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
GlenDsza Nov 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ const config: CodegenConfig = {
User: "../models/User#InterfaceUser",

Venue: "../models/Venue#InterfaceVenue",

VolunteerMembership:
"../models/VolunteerMembership#InterfaceVolunteerMembership",
},

useTypeImports: true,
Expand Down
125 changes: 108 additions & 17 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ type ActionItem {
_id: ID!
actionItemCategory: ActionItemCategory
allotedHours: Float
assignee: User
assignee: EventVolunteer
assigneeGroup: EventVolunteerGroup
assigneeType: String!
assigneeUser: User
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved
assigner: User
assignmentDate: Date!
completionDate: Date!
Expand Down Expand Up @@ -41,6 +44,7 @@ input ActionItemWhereInput {
categoryName: String
event_id: ID
is_completed: Boolean
orgId: ID
}

enum ActionItemsOrderByInput {
Expand Down Expand Up @@ -307,6 +311,7 @@ scalar CountryCode
input CreateActionItemInput {
allotedHours: Float
assigneeId: ID!
assigneeType: String!
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved
dueDate: Date
eventId: ID
preCompletionNotes: String
Expand Down Expand Up @@ -672,6 +677,8 @@ type Event {
startTime: Time
title: String!
updatedAt: DateTime!
volunteerGroups: [EventVolunteerGroup]
volunteers: [EventVolunteer]
}

type EventAttendee {
Expand Down Expand Up @@ -736,21 +743,25 @@ enum EventOrderByInput {

type EventVolunteer {
_id: ID!
assignments: [ActionItem]
createdAt: DateTime!
creator: User
event: Event
group: EventVolunteerGroup
isAssigned: Boolean
isInvited: Boolean
response: String
groups: [EventVolunteerGroup]
hasAccepted: Boolean!
hoursHistory: [HoursHistory]
hoursVolunteered: Float!
isPublic: Boolean!
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved
updatedAt: DateTime!
user: User!
}

type EventVolunteerGroup {
_id: ID!
assignments: [ActionItem]
createdAt: DateTime!
creator: User
description: String
event: Event
leader: User!
name: String
Expand All @@ -760,20 +771,32 @@ type EventVolunteerGroup {
}

input EventVolunteerGroupInput {
description: String
eventId: ID!
name: String
leaderId: ID!
name: String!
volunteerUserIds: [ID!]!
volunteersRequired: Int
}

enum EventVolunteerGroupOrderByInput {
assignments_ASC
assignments_DESC
members_ASC
members_DESC
}
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved

input EventVolunteerGroupWhereInput {
eventId: ID
leaderName: String
name_contains: String
volunteerId: ID
orgId: ID
userId: ID
}

input EventVolunteerInput {
eventId: ID!
groupId: ID!
groupId: ID
userId: ID!
}

Expand All @@ -782,6 +805,19 @@ enum EventVolunteerResponse {
YES
}

input EventVolunteerWhereInput {
eventId: ID
groupId: ID
hasAccepted: Boolean
id: ID
name_contains: String
}

enum EventVolunteersOrderByInput {
hoursVolunteered_ASC
hoursVolunteered_DESC
}

input EventWhereInput {
description: String
description_contains: String
Expand Down Expand Up @@ -939,6 +975,11 @@ type Group {
updatedAt: DateTime!
}

type HoursHistory {
date: Date!
hours: Float!
}

type InvalidCursor implements FieldError {
message: String!
path: [String!]!
Expand Down Expand Up @@ -1093,6 +1134,7 @@ type Mutation {
createUserFamily(data: createUserFamilyInput!): UserFamily!
createUserTag(input: CreateUserTagInput!): UserTag
createVenue(data: VenueInput!): Venue
createVolunteerMembership(data: VolunteerMembershipInput!): VolunteerMembership!
deleteAdvertisement(id: ID!): DeleteAdvertisementPayload
deleteAgendaCategory(id: ID!): ID!
deleteDonationById(id: ID!): DeletePayload!
Expand Down Expand Up @@ -1156,7 +1198,7 @@ type Mutation {
updateCommunity(data: UpdateCommunityInput!): Boolean!
updateEvent(data: UpdateEventInput!, id: ID!, recurrenceRuleData: RecurrenceRuleInput, recurringEventUpdateType: RecurringEventMutationType): Event!
updateEventVolunteer(data: UpdateEventVolunteerInput, id: ID!): EventVolunteer!
updateEventVolunteerGroup(data: UpdateEventVolunteerGroupInput, id: ID!): EventVolunteerGroup!
updateEventVolunteerGroup(data: UpdateEventVolunteerGroupInput!, id: ID!): EventVolunteerGroup!
updateFund(data: UpdateFundInput!, id: ID!): Fund!
updateFundraisingCampaign(data: UpdateFundCampaignInput!, id: ID!): FundraisingCampaign!
updateFundraisingCampaignPledge(data: UpdateFundCampaignPledgeInput!, id: ID!): FundraisingCampaignPledge!
Expand All @@ -1170,6 +1212,7 @@ type Mutation {
updateUserProfile(data: UpdateUserInput, file: String): User!
updateUserRoleInOrganization(organizationId: ID!, role: String!, userId: ID!): Organization!
updateUserTag(input: UpdateUserTagInput!): UserTag
updateVolunteerMembership(id: ID!, status: String!): VolunteerMembership!
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved
}

type Note {
Expand Down Expand Up @@ -1461,6 +1504,7 @@ type Query {
actionItemCategoriesByOrganization(orderBy: ActionItemsOrderByInput, organizationId: ID!, where: ActionItemCategoryWhereInput): [ActionItemCategory]
actionItemsByEvent(eventId: ID!): [ActionItem]
actionItemsByOrganization(eventId: ID, orderBy: ActionItemsOrderByInput, organizationId: ID!, where: ActionItemWhereInput): [ActionItem]
actionItemsByUser(orderBy: ActionItemsOrderByInput, userId: ID!, where: ActionItemWhereInput): [ActionItem]
adminPlugin(orgId: ID!): [Plugin]
advertisementsConnection(after: String, before: String, first: PositiveInt, last: PositiveInt): AdvertisementsConnection
agendaCategory(id: ID!): AgendaCategory!
Expand All @@ -1473,9 +1517,8 @@ type Query {
customDataByOrganization(organizationId: ID!): [UserCustomData!]!
customFieldsByOrganization(id: ID!): [OrganizationCustomField]
event(id: ID!): Event
eventVolunteersByEvent(id: ID!): [EventVolunteer]
eventsByOrganization(id: ID, orderBy: EventOrderByInput): [Event]
eventsByOrganizationConnection(first: Int, orderBy: EventOrderByInput, skip: Int, where: EventWhereInput): [Event!]!
eventsByOrganizationConnection(currentDate: DateTime, first: Int, orderBy: EventOrderByInput, skip: Int, where: EventWhereInput): [Event!]!
fundsByOrganization(orderBy: FundOrderByInput, organizationId: ID!, where: FundWhereInput): [Fund]
getAgendaItem(id: ID!): AgendaItem
getAgendaSection(id: ID!): AgendaSection
Expand All @@ -1488,7 +1531,8 @@ type Query {
getEventAttendee(eventId: ID!, userId: ID!): EventAttendee
getEventAttendeesByEventId(eventId: ID!): [EventAttendee]
getEventInvitesByUserId(userId: ID!): [EventAttendee!]!
getEventVolunteerGroups(where: EventVolunteerGroupWhereInput): [EventVolunteerGroup]!
getEventVolunteerGroups(orderBy: EventVolunteerGroupOrderByInput, where: EventVolunteerGroupWhereInput!): [EventVolunteerGroup]!
getEventVolunteers(orderBy: EventVolunteersOrderByInput, where: EventVolunteerWhereInput!): [EventVolunteer]!
getFundById(id: ID!, orderBy: CampaignOrderByInput, where: CampaignWhereInput): Fund!
getFundraisingCampaignPledgeById(id: ID!): FundraisingCampaignPledge!
getFundraisingCampaigns(campaignOrderby: CampaignOrderByInput, pledgeOrderBy: PledgeOrderByInput, where: CampaignWhereInput): [FundraisingCampaign]!
Expand All @@ -1498,6 +1542,8 @@ type Query {
getUserTag(id: ID!): UserTag
getUserTagAncestors(id: ID!): [UserTag]
getVenueByOrgId(first: Int, orderBy: VenueOrderByInput, orgId: ID!, skip: Int, where: VenueWhereInput): [Venue]
getVolunteerMembership(orderBy: VolunteerMembershipOrderByInput, where: VolunteerMembershipWhereInput!): [VolunteerMembership]
getVolunteerRanks(orgId: ID!, where: VolunteerRankWhereInput!): [VolunteerRank]
getlanguage(lang_code: String!): [Translation]
hasSubmittedFeedback(eventId: ID!, userId: ID!): Boolean
isSampleOrganization(id: ID!): Boolean!
Expand Down Expand Up @@ -1640,6 +1686,7 @@ input UpdateActionItemCategoryInput {
input UpdateActionItemInput {
allotedHours: Float
assigneeId: ID
assigneeType: String
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved
completionDate: Date
dueDate: Date
isCompleted: Boolean
Expand Down Expand Up @@ -1709,16 +1756,16 @@ input UpdateEventInput {
}

input UpdateEventVolunteerGroupInput {
eventId: ID
description: String
eventId: ID!
name: String
volunteersRequired: Int
}

input UpdateEventVolunteerInput {
eventId: ID
isAssigned: Boolean
isInvited: Boolean
response: EventVolunteerResponse
assignments: [ID]
hasAccepted: Boolean
isPublic: Boolean
}

input UpdateFundCampaignInput {
Expand Down Expand Up @@ -2006,6 +2053,50 @@ input VenueWhereInput {
name_starts_with: String
}

type VolunteerMembership {
_id: ID!
createdAt: DateTime!
event: Event!
group: EventVolunteerGroup
status: String!
updatedAt: DateTime!
volunteer: EventVolunteer!
}

input VolunteerMembershipInput {
event: ID!
group: ID
status: String!
userId: ID!
}

enum VolunteerMembershipOrderByInput {
createdAt_ASC
createdAt_DESC
}

input VolunteerMembershipWhereInput {
eventId: ID
eventTitle: String
filter: String
status: String
userId: ID
userName: String
}

type VolunteerRank {
hoursVolunteered: Float!
rank: Int!
user: User!
}

input VolunteerRankWhereInput {
limit: Int
nameContains: String
orderBy: String!
timeFrame: String!
}
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved

enum WeekDays {
FRIDAY
MONDAY
Expand Down
22 changes: 21 additions & 1 deletion src/models/ActionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import type { InterfaceEvent } from "./Event";
import type { InterfaceActionItemCategory } from "./ActionItemCategory";
import { MILLISECONDS_IN_A_WEEK } from "../constants";
import type { InterfaceOrganization } from "./Organization";
import type { InterfaceEventVolunteerGroup } from "./EventVolunteerGroup";
import type { InterfaceEventVolunteer } from "./EventVolunteer";

/**
* Interface representing a database document for ActionItem in MongoDB.
*/
export interface InterfaceActionItem {
_id: Types.ObjectId;
assignee: PopulatedDoc<InterfaceUser & Document>;
assignee: PopulatedDoc<InterfaceEventVolunteer & Document>;
assigneeGroup: PopulatedDoc<InterfaceEventVolunteerGroup & Document>;
assigneeUser: PopulatedDoc<InterfaceUser & Document>;
assigneeType: "EventVolunteer" | "EventVolunteerGroup";
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved
assigner: PopulatedDoc<InterfaceUser & Document>;
actionItemCategory: PopulatedDoc<
InterfaceActionItemCategory & Document
Expand All @@ -33,6 +38,9 @@ export interface InterfaceActionItem {
/**
* Defines the schema for the ActionItem document.
* @param assignee - User to whom the ActionItem is assigned.
* @param assigneeGroup - Group to whom the ActionItem is assigned.
* @param assigneeUser - Organization User to whom the ActionItem is assigned.
* @param assigneeType - Type of assignee (User or Group).
* @param assigner - User who assigned the ActionItem.
* @param actionItemCategory - ActionItemCategory to which the ActionItem belongs.
* @param preCompletionNotes - Notes recorded before completion.
Expand All @@ -51,9 +59,21 @@ export interface InterfaceActionItem {
const actionItemSchema = new Schema(
{
assignee: {
type: Schema.Types.ObjectId,
ref: "EventVolunteer",
},
assigneeGroup: {
type: Schema.Types.ObjectId,
ref: "EventVolunteerGroup",
},
assigneeUser: {
type: Schema.Types.ObjectId,
ref: "User",
},
assigneeType: {
type: String,
required: true,
enum: ["EventVolunteer", "EventVolunteerGroup", "User"],
GlenDsza marked this conversation as resolved.
Show resolved Hide resolved
},
assigner: {
type: Schema.Types.ObjectId,
Expand Down
11 changes: 11 additions & 0 deletions src/models/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createLoggingMiddleware } from "../libraries/dbLogger";
import type { InterfaceEventVolunteerGroup } from "./EventVolunteerGroup";
import type { InterfaceRecurrenceRule } from "./RecurrenceRule";
import type { InterfaceAgendaItem } from "./AgendaItem";
import type { InterfaceEventVolunteer } from "./EventVolunteer";

/**
* Represents a document for an event in the MongoDB database.
Expand Down Expand Up @@ -37,6 +38,7 @@ export interface InterfaceEvent {
startTime: string | undefined;
title: string;
updatedAt: Date;
volunteers: PopulatedDoc<InterfaceEventVolunteer & Document>[];
volunteerGroups: PopulatedDoc<InterfaceEventVolunteerGroup & Document>[];
agendaItems: PopulatedDoc<InterfaceAgendaItem & Document>[];
}
Expand Down Expand Up @@ -66,6 +68,7 @@ export interface InterfaceEvent {
* @param admins - Array of admins for the event.
* @param organization - Reference to the organization hosting the event.
* @param volunteerGroups - Array of volunteer groups associated with the event.
* @param volunteers - Array of volunteers associated with the event.
* @param createdAt - Timestamp of when the event was created.
* @param updatedAt - Timestamp of when the event was last updated.
*/
Expand Down Expand Up @@ -178,6 +181,14 @@ const eventSchema = new Schema(
ref: "Organization",
required: true,
},
volunteers: [
{
type: Schema.Types.ObjectId,
ref: "EventVolunteer",
required: true,
default: [],
},
],
volunteerGroups: [
{
type: Schema.Types.ObjectId,
Expand Down
Loading
Loading