@@ -537,59 +537,60 @@ object CommonServices {
537
537
}
538
538
}
539
539
def getAllTags (research : String )(implicit
540
- ctx : DaikokuActionContext [_ ],
541
- env : Env ,
542
- ec : ExecutionContext
540
+ ctx : DaikokuActionContext [JsValue ],
541
+ env : Env ,
542
+ ec : ExecutionContext
543
543
): Future [Seq [String ]] = {
544
544
for {
545
- apis <- env.dataStore.apiRepo.forTenant(ctx.tenant.id).findAllNotDeleted( )
545
+ visibleApis <- getVisibleApis(research = " " , limit = - 1 , offset = 0 )
546
546
} yield {
547
- apis
548
- .flatMap(api =>
549
- api.tags.toSeq.filter(tag => tag.indexOf(research) != - 1 )
550
- )
551
- .foldLeft(Map .empty[String , Int ])((map, tag) => {
552
- val nbOfMatching = map.get(tag) match {
553
- case Some (count) => count + 1
554
- case None => 1
555
- }
556
- map + (tag -> nbOfMatching)
557
-
558
- })
559
- .toSeq
560
- .sortBy(_._2)
561
- .reverse
562
- .map(a => a._1)
563
- .take(5 )
547
+ visibleApis
548
+ .map(apis => apis.apis.flatMap(api =>
549
+ api.api.tags.toSeq.filter(tag => tag.indexOf(research) != - 1 )
550
+ )
551
+ .foldLeft(Map .empty[String , Int ])((map, tag) => {
552
+ val nbOfMatching = map.get(tag) match {
553
+ case Some (count) => count + 1
554
+ case None => 1
555
+ }
556
+ map + (tag -> nbOfMatching)
564
557
558
+ })
559
+ .toSeq
560
+ .sortBy(_._2)
561
+ .reverse
562
+ .map(a => a._1)
563
+ .take(5 ))
564
+ .getOrElse(Seq .empty)
565
565
}
566
566
}
567
567
568
568
def getAllCategories (research : String )(implicit
569
- ctx : DaikokuActionContext [_ ],
569
+ ctx : DaikokuActionContext [JsValue ],
570
570
env : Env ,
571
571
ec : ExecutionContext
572
572
): Future [Seq [String ]] = {
573
573
for {
574
- apis <- env.dataStore.apiRepo.forTenant(ctx.tenant.id).findAllNotDeleted( )
574
+ visibleApis <- getVisibleApis(research = " " , limit = - 1 , offset = 0 )
575
575
} yield {
576
- apis
577
- .flatMap(api =>
578
- api.categories.toSeq.filter(cat => cat .indexOf(research) != - 1 )
579
- )
580
- .foldLeft(Map .empty[String , Int ])((map, cat) => {
581
- val nbOfMatching = map.get(cat) match {
582
- case Some (count) => count + 1
583
- case None => 1
584
- }
585
- map + (cat -> nbOfMatching)
576
+ visibleApis
577
+ .map(apis => apis.apis. flatMap(api =>
578
+ api.api. categories.toSeq.filter(tag => tag .indexOf(research) != - 1 )
579
+ )
580
+ .foldLeft(Map .empty[String , Int ])((map, cat) => {
581
+ val nbOfMatching = map.get(cat) match {
582
+ case Some (count) => count + 1
583
+ case None => 1
584
+ }
585
+ map + (cat -> nbOfMatching)
586
586
587
- })
588
- .toSeq
589
- .sortBy(_._2)
590
- .reverse
591
- .map(a => a._1)
592
- .take(5 )
587
+ })
588
+ .toSeq
589
+ .sortBy(_._2)
590
+ .reverse
591
+ .map(a => a._1)
592
+ .take(5 ))
593
+ .getOrElse(Seq .empty)
593
594
}
594
595
}
595
596
0 commit comments