//GetPlayerNumber returns the number of occupied slots in the lobby
771971
func (lobby *Lobby) GetPlayerNumber() int {
	count := 0
	err := db.DB.Model(&LobbySlot{}).Where("lobby_id = ?", lobby.ID).Count(&count).Error
	if err != nil {
		return 0
	}
	return count
}
617358
func (c *Client) GetPlaylist(playlistID ID) (*FullPlaylist, error) {
	return c.GetPlaylistOpt(playlistID, "")
}
585768
func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, blockNr rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) {
	block, err := s.b.BlockByNumber(ctx, blockNr)
	if block != nil {
		response, err := s.rpcOutputBlock(block, true, fullTx)
		if err == nil && blockNr == rpc.PendingBlockNumber {
			// Pending blocks need to nil out a few fields
			for _, field := range []string{"hash", "nonce", "miner"} {
				response[field] = nil
			}
		}
		return response, err
	}
	return nil, err
}
468295
func (player *Player) IsSpectatingID(lobbyid uint) bool {
	count := 0
	db.DB.Table("spectators_players_lobbies").Where("player_id = ? AND lobby_id = ?", player.ID, lobbyid).Count(&count)
	return count != 0
}
505938
func (s *GameSession) SetCurrentPlayerSessionCount(v int64) *GameSession {
	s.CurrentPlayerSessionCount = &v
	return s
}
1232382
func (c *Client) GetPlaylistTracks(playlistID ID) (*PlaylistTrackPage, error) {
	return c.GetPlaylistTracksOpt(playlistID, nil, "")
}
423670
func (c *Client) PlaylistRename(name, newName string) error {
	return c.Command("rename %s %s", name, newName).OK()
}
613840
func (player *Player) GetLobbyID(excludeInProgress bool) (uint, error) {
	states := []int{5} //Ended
	if excludeInProgress {
		states = append(states, 3) //3 == in progress
	}
	var lobbyID uint

	err := db.DB.Select("lobbies.id").Table("lobbies").
		Joins("INNER JOIN lobby_slots ON lobbies.id = lobby_slots.lobby_id").
		Where("lobby_slots.player_id = ? AND lobbies.state NOT IN (?) AND lobby_slots.needs_sub = FALSE", player.ID, states).
		Row().Scan(&lobbyID)

	if err != nil {
		return 0, err
	}

	return lobbyID, nil
}
288539
func (lobby *Lobby) IsPlayerReady(player *player.Player) (bool, error) {
	var ready bool
	err := db.DB.DB().QueryRow("SELECT ready FROM lobby_slots WHERE lobby_id = $1 AND player_id = $2", lobby.ID, player.ID).Scan(&ready)
	return ready, err
}
415014
func NewPlayer(sampleRate, channelNum, bitDepthInBytes, bufferSizeInBytes int) (*Player, error) {
	c, err := NewContext(sampleRate, channelNum, bitDepthInBytes, bufferSizeInBytes)
	if err != nil {
		return nil, err
	}
	return c.NewPlayer(), nil
}
1133771
func (lobby *Lobby) UnreadyAllPlayers() error {
	lobby.Lock()
	err := db.DB.Model(&LobbySlot{}).Where("lobby_id = ?", lobby.ID).UpdateColumn("ready", false).Error
	lobby.Unlock()

	lobby.OnChange(false)
	return err
}
834715
func (l Players) GetPlayer(name string) *player.Player {
	l.RLock()
	defer l.RUnlock()
	return l.list[name]
}
968145
func (lobby *Lobby) GetSlotRequirement(slot int) (*Requirement, error) {
	req := &Requirement{}
	err := db.DB.Model(&Requirement{}).Where("lobby_id = ? AND slot = ?", lobby.ID, slot).First(req).Error

	if req.Hours == 0 {
		req.Hours = 150
	}

	return req, err
}
152167
func (f *FieldInfo) IsNumber() bool {
	return f.IsInt() || f.IsInt64() || f.IsFloat32() || f.IsFloat64()
}
947091
func (t *TeamDiscussion) GetNumber() int {
	if t == nil || t.Number == nil {
		return 0
	}
	return *t.Number
}
702723
func (c *Client) GetCategoryPlaylistsOpt(catID string, opt *Options) (*SimplePlaylistPage, error) {
	spotifyURL := fmt.Sprintf("%sbrowse/categories/%s/playlists", c.baseURL, catID)
	if opt != nil {
		values := url.Values{}
		if opt.Country != nil {
			values.Set("country", *opt.Country)
		}
		if opt.Limit != nil {
			values.Set("limit", strconv.Itoa(*opt.Limit))
		}
		if opt.Offset != nil {
			values.Set("offset", strconv.Itoa(*opt.Offset))
		}
		if query := values.Encode(); query != "" {
			spotifyURL += "?" + query
		}
	}

	wrapper := struct {
		Playlists SimplePlaylistPage `json:"playlists"`
	}{}

	err := c.get(spotifyURL, &wrapper)
	if err != nil {
		return nil, err
	}

	return &wrapper.Playlists, nil
}
430996
func (s *Stream) OnlineUserNum() (num int64) {
	resp := OnlineInfoResponse{}
	s.live.StreamOnlineUserNum(s.StreamName, &resp)
	num = resp.TotalUserNumber
	return
}