Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return populated room object when joined #11675

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smoogipoo
Copy link
Contributor

While in the lounge, the client polls using index() which returns a compact model that in particular excludes the playlist. After the room is joined the playlist becomes important for the obvious reason that the user should be able to start playing, but also for the less-obvious reason that the client expects the playlist to be populated in order to preselect the first available item.

Rather than adding a special condition for the client, it seems to make more sense to return the complete model here and potentially remove the show() API request. As far as I can tell the only remaining use (as far as the client's concerned) is to update the recent participants list, but it's otherwise quite wasteful and polls every 5 seconds.
Beyond that, I believe playlists would be better served by the multiplayer server like daily challenge where statistics are pushed to the client in real time.

I noticed that the response was already mostly duplicated between store() and show(), so I took the liberty of splitting it out. Let me know if this is the correct way of doing things :)

Sample returned model:

{
  "id" : 1,
  "name" : "smgi's awesome playlist",
  "category" : "normal",
  "type" : "playlists",
  "user_id" : 156,
  "starts_at" : "2024-11-21T14:04:18+00:00",
  "ends_at" : "2024-11-21T14:34:18+00:00",
  "max_attempts" : null,
  "participant_count" : 0,
  "channel_id" : 1,
  "active" : false,
  "has_password" : false,
  "queue_mode" : "host_only",
  "auto_skip" : false,
  "current_user_score" : {
    "accuracy" : 0,
    "attempts" : 0,
    "completed" : 0,
    "pp" : 0,
    "room_id" : 1,
    "total_score" : 0,
    "user_id" : 156,
    "playlist_item_attempts" : [ ]
  },
  "host" : {
    "avatar_url" : "http://localhost:8080/images/layout/[email protected]",
    "country_code" : null,
    "default_group" : "default",
    "id" : 156,
    "is_active" : true,
    "is_bot" : false,
    "is_deleted" : false,
    "is_online" : true,
    "is_supporter" : false,
    "last_visit" : "2024-11-21T15:03:48+00:00",
    "pm_friends_only" : false,
    "profile_colour" : null,
    "username" : "smgi",
    "country" : null
  },
  "playlist" : [ {
    "id" : 1,
    "room_id" : 1,
    "beatmap_id" : 830459,
    "ruleset_id" : 0,
    "allowed_mods" : [ ],
    "required_mods" : [ ],
    "expired" : false,
    "owner_id" : 156,
    "playlist_order" : null,
    "played_at" : null,
    "beatmap" : {
      "beatmapset_id" : 379370,
      "difficulty_rating" : 1.86,
      "id" : 830459,
      "mode" : "osu",
      "status" : "ranked",
      "total_length" : 147,
      "user_id" : 4,
      "version" : "Normal",
      "beatmapset" : {
        "artist" : "SoundTeMP",
        "artist_unicode" : "SoundTeMP",
        "covers" : {
          "cover" : "http://localhost:8080/uploads/beatmaps/379370/covers/cover.jpg?0",
          "cover@2x" : "http://localhost:8080/uploads/beatmaps/379370/covers/[email protected]?0",
          "card" : "http://localhost:8080/uploads/beatmaps/379370/covers/card.jpg?0",
          "card@2x" : "http://localhost:8080/uploads/beatmaps/379370/covers/[email protected]?0",
          "list" : "http://localhost:8080/uploads/beatmaps/379370/covers/list.jpg?0",
          "list@2x" : "http://localhost:8080/uploads/beatmaps/379370/covers/[email protected]?0",
          "slimcover" : "http://localhost:8080/uploads/beatmaps/379370/covers/slimcover.jpg?0",
          "slimcover@2x" : "http://localhost:8080/uploads/beatmaps/379370/covers/[email protected]?0"
        },
        "creator" : "neonat",
        "favourite_count" : 51,
        "hype" : null,
        "id" : 379370,
        "nsfw" : false,
        "offset" : 0,
        "play_count" : 10556,
        "preview_url" : "//b.ppy.sh/preview/379370.mp3",
        "source" : "Ragnarok Online",
        "spotlight" : false,
        "status" : "ranked",
        "title" : "Christmas in 13th Month (Vesuvia Ecky's Poetic Mix)",
        "title_unicode" : "Christmas in 13th Month (Vesuvia Ecky's Poetic Mix)",
        "track_id" : null,
        "user_id" : 8,
        "video" : false
      },
      "checksum" : "821afc7f47448c51edf71d004fbb3e23",
      "max_combo" : null
    }
  } ],
  "recent_participants" : [ ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant