pub async fn get_available_games(
server_state: ServerState,
user_id: UserId,
filter: String,
last_created_at: Option<DateTime<Utc>>,
) -> Result<(Vec<AvailableGame>, bool, Option<DateTime<Utc>>), ServerError>Expand description
Retrieves a list of available games that the specified user can play or join.
This function fetches games from the server that the specified user
is eligible to join. Results can be filtered by a search string and
paginated using the last_created_at parameter.
§Parameters
server_state: The shared server state containing the games database.user_id: The ID of the user requesting the available games.filter: A string used to filter games by name or other criteria.last_created_at: Optional timestamp for pagination; only games created after this timestamp are returned.
§Returns
Returns a tuple (games, has_more, last_created_at):
games: AVec<AvailableGame>containing the available games matching the filter and pagination criteria.has_more:trueif there are more games to fetch beyond this page.last_created_at: The timestamp of the last game returned, to be used for the next paginated request.
Returns a ServerError if there is a problem accessing the database or
processing the request.