Skip to content

Commit

Permalink
lil stuff
Browse files Browse the repository at this point in the history
replace all instances of `author` with `owner`.
implement v1.PackageFromCommunity.
implement v1.PackagesFromCommunity.
  • Loading branch information
Owen3H committed May 8, 2024
1 parent adeb2eb commit 54f0a64
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
23 changes: 12 additions & 11 deletions v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import (
"golang.org/x/sync/errgroup"
)

// // The list of every package on Thunderstore across every community.
// func GetAllPackages() (PackageList, error) {
// communities, err := Exp.GetCommunities()
func PackagesFromCommunity(identifier string) (PackageList, error) {
comm := Community{
Identifier: identifier,
}

// if err != nil {
// return nil, err
// }
return comm.AllPackages()
}

// identifiers := lop.Map(communities, func(c Exp.Community, _ int) string {
// return c.Identifier
// })
func PackageFromCommunity(identifier string, owner string, packageName string) *Package {
comm := Community{
Identifier: identifier,
}

// return PackagesFromCommunities(NewCommunityList(identifiers...))
// }
return comm.GetPackage(owner, packageName)
}

// Returns a single slice with all packages from the specified communities.
func PackagesFromCommunities(communities []Community) (PackageList, error) {
Expand Down
4 changes: 2 additions & 2 deletions v1/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (comm Community) AllPackages(predicate ...func(item Package, index int) boo
}

// Gets a single package from this community given the owner and package name.
func (comm Community) GetPackage(author string, name string) *Package {
func (comm Community) GetPackage(owner string, name string) *Package {
// if pkgCache != nil {
// return pkgCache.Get(author, name)
// }
Expand All @@ -45,5 +45,5 @@ func (comm Community) GetPackage(author string, name string) *Package {
return nil
}

return pkgs.Get(author, name)
return pkgs.Get(owner, name)
}
4 changes: 2 additions & 2 deletions v1/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func (original *PackageList) ToMap() map[string]Package {
}

// Grab a single package from the list given the package owner's name and the package's short name.
func (list PackageList) Get(author string, name string) *Package {
func (list PackageList) Get(owner string, name string) *Package {
return util.TryFind(list, func(p Package) bool {
return strings.EqualFold(p.Name, name) && strings.EqualFold(p.Owner, author)
return strings.EqualFold(p.Name, name) && strings.EqualFold(p.Owner, owner)
})
}

Expand Down

0 comments on commit 54f0a64

Please sign in to comment.