Skip to content

Commit

Permalink
fix: Fix conflicts caused by merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Maximino committed Nov 11, 2022
2 parents 8ff7f77 + ab912df commit 2f22660
Show file tree
Hide file tree
Showing 84 changed files with 5,430 additions and 697 deletions.
74 changes: 74 additions & 0 deletions backend/src/models/meeting.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,76 @@
package models

import (
"errors"
"time"

"go.mongodb.org/mongo-driver/bson/primitive"
)

type MeetingKind string
type MeetingParticipantKind string

const (
EventMeeting MeetingKind = "EVENT"
TeamMeeting MeetingKind = "TEAM"
CompanyMeeting MeetingKind = "COMPANY"
)

const (
MemberParticipant MeetingParticipantKind = "MEMBER"
CompanyRepParticipant MeetingParticipantKind = "COMPANYREP"
)

func (mk *MeetingKind) Parse(kind string) error {

var newMeetingKind MeetingKind

switch kind {

case string(EventMeeting):
newMeetingKind = EventMeeting
break

case string(TeamMeeting):
newMeetingKind = TeamMeeting
break

case string(CompanyMeeting):
newMeetingKind = CompanyMeeting
break

default:
return errors.New("invalid kind")

}

*mk = newMeetingKind
return nil
}

func (mk *MeetingParticipantKind) Parse(participantKind string) error {

var newMeetingParticipantKind MeetingParticipantKind

switch participantKind {

case string(MemberParticipant):
newMeetingParticipantKind = MemberParticipant
break

case string(CompanyRepParticipant):
newMeetingParticipantKind = CompanyRepParticipant
break

default:
return errors.New("invalid type of participant")

}

*mk = newMeetingParticipantKind
return nil
}

type MeetingParticipants struct {

// Members is an array of _id of Member (see models.Member).
Expand All @@ -22,6 +87,12 @@ type Meeting struct {
// Meeting's ID (_id of mongodb).
ID primitive.ObjectID `json:"id" bson:"_id"`

// The title of the meeting
Title string `json:"title" bson:"title"`

// Type of the meeting
Kind MeetingKind `json:"kind" bson:"kind"`

Begin time.Time `json:"begin" bson:"begin"`
End time.Time `json:"end" bson:"end"`

Expand All @@ -33,5 +104,8 @@ type Meeting struct {
// "Ata" in portuguese.
Minute string `json:"minute" bson:"minute"`

// Communications is an array of _id of Communication (see models.Communication).
Communications []primitive.ObjectID `json:"communications" bson:"communications"`

Participants MeetingParticipants `json:"participants" bson:"participants"`
}
3 changes: 2 additions & 1 deletion backend/src/models/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const (

NotificationKindUpdatedPrivateImage NotificationKind = "UPDATED_PRIVATE_IMAGE"
NotificationKindUpdatedPublicImage NotificationKind = "UPDATED_PUBLIC_IMAGE"
NotificationKindUploadedMeetingMinute NotificationKind = "UPDLOADED_MEETING_MINUTE"
NotificationKindUploadedMeetingMinute NotificationKind = "UPLOADED_MEETING_MINUTE"
NotificationKindDeletedMeetingMinute NotificationKind = "DELETED_MEETING_MINUTE"

// Speaker's company image
NotificationKindUpdatedCompanyImage NotificationKind = "UPDATED_COMPANY_IMAGE"
Expand Down
26 changes: 13 additions & 13 deletions backend/src/mongodb/company.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,25 @@ func (c *CompaniesType) GetCompanies(compOptions GetCompaniesOptions) ([]*models
case string(NumberParticipations):
query := mongo.Pipeline{
{
{"$match", filter},
{Key: "$match", Value: filter},
},
{
{"$addFields", bson.D{
{"numParticipations", bson.D{
{"$size", "$participations"},
{Key: "$addFields", Value: bson.D{
{Key: "numParticipations", Value: bson.D{
{Key: "$size", Value: "$participations"},
}},
}},
},
{
{"$sort", bson.D{
{"numParticipations", -1},
{Key: "$sort", Value: bson.D{
{Key: "numParticipations", Value: -1},
}},
},
{
{"$skip", (*compOptions.NumRequests * (*compOptions.MaxCompInRequest))},
{Key: "$skip", Value: (*compOptions.NumRequests * (*compOptions.MaxCompInRequest))},
},
{
{"$limit", *compOptions.MaxCompInRequest},
{Key: "$limit", Value: *compOptions.MaxCompInRequest},
},
}
cur, err = c.Collection.Aggregate(ctx, query)
Expand All @@ -187,18 +187,18 @@ func (c *CompaniesType) GetCompanies(compOptions GetCompaniesOptions) ([]*models
case string(LastParticipation):
query := mongo.Pipeline{
{
{"$match", filter},
{Key: "$match", Value: filter},
},
{
{"$sort", bson.D{
{"participations.event", -1},
{Key: "$sort", Value: bson.D{
{Key: "participations.event", Value: -1},
}},
},
{
{"$skip", (*compOptions.NumRequests * (*compOptions.MaxCompInRequest))},
{Key: "$skip", Value: (*compOptions.NumRequests * (*compOptions.MaxCompInRequest))},
},
{
{"$limit", *compOptions.MaxCompInRequest},
{Key: "$limit", Value: *compOptions.MaxCompInRequest},
},
}
cur, err = c.Collection.Aggregate(ctx, query)
Expand Down
Loading

0 comments on commit 2f22660

Please sign in to comment.