Skip to content

Retrieving users for an event returns all users in guild from cache (Incorrectly) #622

Open
@TRiGGY

Description

@TRiGGY

When I retrieve a GuildScheduledEvent and access it's users or members property. The list returned contains all users in the guild instead of all users that have signed up for the event. I am using caching and I traced this issue back to the following CacheEntitySupplier code:

override fun getGuildScheduledEventMembersAfter(
        guildId: Snowflake,
        eventId: Snowflake,
        after: Snowflake,
        limit: Int?,
    ): Flow<Member> {
        checkLimit(limit)
        return cache
            .query<MemberData> {
                idGt(MemberData::userId, after)
                idEq(MemberData::guildId, guildId)
            }
            .asFlow()
            .mapNotNull {
                val userData = cache.query<UserData> { idEq(UserData::id, it.userId) }.singleOrNull()
                    ?: return@mapNotNull null
                Member(it, userData, kord)
            }
            .limit(limit)
    }

At no point are users filtered for the relevant event. This information isn't stored in MemberData as far as I can tell.
The code that runs in the RestEntitySupplier does return the expected results of only users that have signed up for an event.

Activity

HopeBaron

HopeBaron commented on Jun 23, 2022

@HopeBaron
Member

Thanks for the report and sorry for the delay.

I'll look into it when possible

HopeBaron

HopeBaron commented on Jun 25, 2022

@HopeBaron
Member

Back to you on this one, we don't seem to cache the members of the scheduled events regardless of the code provided being incorrect.

TRiGGY

TRiGGY commented on Jun 25, 2022

@TRiGGY
Author

The cache with MemberData items will still be filled when members are retrieved from the Guild. My code does that too. Therefore the cache will be filled and wrong items are returned. I'll make an attempt to fix this myself tomorrow.

HopeBaron

HopeBaron commented on Jun 26, 2022

@HopeBaron
Member

In order to fix this we need to introduce a new ScheduledEventMember that contains eventId - user - member given by discord
and make a data model to store it in cache

HopeBaron

HopeBaron commented on Jun 27, 2022

@HopeBaron
Member

Please keep an eye on #631

self-assigned this
on Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

    Participants

    @TRiGGY@HopeBaron@lukellmann

    Issue actions

      Retrieving users for an event returns all users in guild from cache (Incorrectly) · Issue #622 · kordlib/kord