forked from nite/go-igdb
u
This commit is contained in:
@@ -2,7 +2,6 @@ package igdb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
pb "github.com/bestnite/go-igdb/proto"
|
||||
|
||||
@@ -26,58 +25,3 @@ func (g *Client) GetPopularityPrimitives(query string) ([]*pb.PopularityPrimitiv
|
||||
|
||||
return data.Popularityprimitives, nil
|
||||
}
|
||||
|
||||
func (g *Client) GetPopularityPrimitiveByID(id uint64) (*pb.PopularityPrimitive, error) {
|
||||
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||
popularityPrimitives, err := g.GetPopularityPrimitives(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return popularityPrimitives[0], nil
|
||||
}
|
||||
|
||||
func (g *Client) GetPopularityPrimitivesByIDs(ids []uint64) ([]*pb.PopularityPrimitive, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
}
|
||||
|
||||
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||
|
||||
return g.GetPopularityPrimitives(idStr)
|
||||
}
|
||||
|
||||
// GetPopularityPrimitive retrieves popular IGDB game IDs based on a given popularity type.
|
||||
// popularity_type = 1 IGDB Visits
|
||||
// popularity_type = 2 IGDB Want to Play
|
||||
// popularity_type = 3 IGDB Playing
|
||||
// popularity_type = 4 IGDB Played
|
||||
func (g *Client) GetPopularityPrimitivesByPopularityType(popularityType, offset, limit int) ([]*pb.PopularityPrimitive, error) {
|
||||
query := fmt.Sprintf("fields game_id,value,popularity_type; sort value desc; limit %d; offset %d; where popularity_type = %d;", limit, offset, popularityType)
|
||||
return g.GetPopularityPrimitives(query)
|
||||
}
|
||||
|
||||
func (g *Client) GetPopularityPrimitivesByExternalPopularitySourceID(id uint64) ([]*pb.PopularityPrimitive, error) {
|
||||
query := fmt.Sprintf(`where external_popularity_source = %d; fields *;`, id)
|
||||
return g.GetPopularityPrimitives(query)
|
||||
}
|
||||
|
||||
func (g *Client) GetPopularityPrimitivesByExternalPopularitySourceIDs(ids []uint64) ([]*pb.PopularityPrimitive, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
}
|
||||
|
||||
idStr := fmt.Sprintf(`where external_popularity_source = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||
|
||||
return g.GetPopularityPrimitives(idStr)
|
||||
}
|
||||
|
||||
func (g *Client) GetPopularityPrimitivesLength() (int, error) {
|
||||
query := `fields *; sort id desc; limit 1;`
|
||||
popularityPrimitives, err := g.GetPopularityPrimitives(query)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int(popularityPrimitives[0].Id), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user