@@ -37,6 +37,7 @@ func sessionToPublic(session models.Session, eventID *int) (*models.SessionPubli
3737 Begin : session .Begin ,
3838 End : session .End ,
3939 Title : session .Title ,
40+ Image : session .Image ,
4041 Description : session .Description ,
4142 Place : session .Place ,
4243 Kind : session .Kind ,
@@ -492,55 +493,27 @@ func (s *SessionsType) GetSessions(options GetSessionsOptions) ([]*models.Sessio
492493type GetSessionsPublicOptions struct {
493494 EventID * int
494495 Kind * models.SessionKind
496+ Company * primitive.ObjectID
497+ Speaker * primitive.ObjectID
495498}
496499
497500// GetPublicSessions gets all sessions specified with a query to be shown publicly
498501func (s * SessionsType ) GetPublicSessions (options GetSessionsPublicOptions ) ([]* models.SessionPublic , error ) {
499502 ctx = context .Background ()
500503
501504 var public = make ([]* models.SessionPublic , 0 )
502- var filtered = make ([]* models.Session , 0 )
503505 var sessions []* models.Session
504506 var err error
505507
506- if currentPublicCompanies != nil {
507-
508- var filtered = make ([]* models.SessionPublic , 0 )
509-
510- if options .Kind != nil {
511-
512- for _ , s := range * currentPublicSessions {
513- if s .Kind == * options .Kind {
514- filtered = append (filtered , s )
515- }
516- }
517-
518- } else {
519- filtered = * currentPublicSessions
520- }
521-
522- // return cached value
523- return filtered , nil
524-
525- }
526-
527- sessions , err = Sessions .GetSessions (GetSessionsOptions {Event : options .EventID })
508+ sessions , err = Sessions .GetSessions (GetSessionsOptions {
509+ Event : options .EventID ,
510+ Kind : options .Kind ,
511+ Company : options .Company ,
512+ Speaker : options .Speaker })
528513 if err != nil {
529514 return nil , err
530515 }
531516
532- if options .Kind != nil {
533-
534- for _ , s := range sessions {
535- if s .Kind == * options .Kind {
536- filtered = append (filtered , s )
537- }
538- }
539-
540- } else {
541- filtered = sessions
542- }
543-
544517 var event * models.Event
545518 if options .EventID == nil {
546519 event , err = Events .GetCurrentEvent ()
@@ -554,15 +527,15 @@ func (s *SessionsType) GetPublicSessions(options GetSessionsPublicOptions) ([]*m
554527 }
555528 }
556529
557- for _ , session := range filtered {
530+ for _ , session := range sessions {
558531 p , err := sessionToPublic (* session , & event .ID )
559532 if err != nil {
560533 return nil , err
561534 }
562535 public = append (public , p )
563536 }
564537
565- if options .EventID == nil && options .Kind == nil && currentPublicSessions == nil {
538+ if options .EventID == nil && options .Kind == nil && options . Company == nil && options . Speaker == nil && currentPublicSessions == nil {
566539 currentPublicSessions = & public
567540 }
568541
0 commit comments