@@ -37,6 +37,7 @@ func sessionToPublic(session models.Session, eventID *int) (*models.SessionPubli
37
37
Begin : session .Begin ,
38
38
End : session .End ,
39
39
Title : session .Title ,
40
+ Image : session .Image ,
40
41
Description : session .Description ,
41
42
Place : session .Place ,
42
43
Kind : session .Kind ,
@@ -492,55 +493,27 @@ func (s *SessionsType) GetSessions(options GetSessionsOptions) ([]*models.Sessio
492
493
type GetSessionsPublicOptions struct {
493
494
EventID * int
494
495
Kind * models.SessionKind
496
+ Company * primitive.ObjectID
497
+ Speaker * primitive.ObjectID
495
498
}
496
499
497
500
// GetPublicSessions gets all sessions specified with a query to be shown publicly
498
501
func (s * SessionsType ) GetPublicSessions (options GetSessionsPublicOptions ) ([]* models.SessionPublic , error ) {
499
502
ctx = context .Background ()
500
503
501
504
var public = make ([]* models.SessionPublic , 0 )
502
- var filtered = make ([]* models.Session , 0 )
503
505
var sessions []* models.Session
504
506
var err error
505
507
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 })
528
513
if err != nil {
529
514
return nil , err
530
515
}
531
516
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
-
544
517
var event * models.Event
545
518
if options .EventID == nil {
546
519
event , err = Events .GetCurrentEvent ()
@@ -554,15 +527,15 @@ func (s *SessionsType) GetPublicSessions(options GetSessionsPublicOptions) ([]*m
554
527
}
555
528
}
556
529
557
- for _ , session := range filtered {
530
+ for _ , session := range sessions {
558
531
p , err := sessionToPublic (* session , & event .ID )
559
532
if err != nil {
560
533
return nil , err
561
534
}
562
535
public = append (public , p )
563
536
}
564
537
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 {
566
539
currentPublicSessions = & public
567
540
}
568
541
0 commit comments