Skip to content

Commit

Permalink
Update api.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Apr 23, 2024
1 parent 1acae78 commit 6119cc5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions v1/api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1

import (
"fmt"
"sync"

"golang.org/x/sync/errgroup"
Expand All @@ -26,18 +27,22 @@ func GetAllPackages() (PackageList, error) {

// Returns a single slice with all packages from the specified communities.
func PackagesFromCommunities(communities []Community) (PackageList, error) {
amt := len(communities)
var list PackageList
var mut sync.Mutex

g := errgroup.Group{}
g.SetLimit(300)

var list PackageList
var mut sync.Mutex
fmt.Println(len(communities))

for i := 0; i < amt; i++ {
for i := 0; i < len(communities); i++ {
i := i
g.Go(func() error {
pkgs, err := communities[i].AllPackages()
comm := communities[i]

pkgs, err := comm.AllPackages()
//fmt.Println(pkgs.Size())

if err != nil {
return err
}
Expand All @@ -53,6 +58,5 @@ func PackagesFromCommunities(communities []Community) (PackageList, error) {
}

err := g.Wait()

return list, err
}

0 comments on commit 6119cc5

Please sign in to comment.