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

Implement nickname filter for avatar field #420

Open
Atralupus opened this issue Oct 24, 2024 · 3 comments
Open

Implement nickname filter for avatar field #420

Atralupus opened this issue Oct 24, 2024 · 3 comments

Comments

@Atralupus
Copy link
Member

Atralupus commented Oct 24, 2024

Currently, avatars can only be queried using their address. However, in the game, most users rely on nicknames, and it would be more intuitive for users to search for avatars by nickname through Mimir.
image

Here’s how the data is stored in the database:
image

Desired Query Example:

query {
  avatar(nickname: "atralupus") {
    address
    agentAddress
  }
}

Steps to Implement:

  1. Update AvatarRepository
    Add a new method GetByNicknameAsync to search by nickname. Use the following filter:

    var filter = Builders<AvatarDocument>.Filter.Eq("Object.Name", nickname);
  2. Update Query
    Modify the GraphQL query to accept nickname as a parameter.

    Example:

    public async Task<AvatarState> GetAvatarAsync(
        Address? address,
        string? nickname,
        [Service] AvatarRepository repo
    )
    {
        if (address is not null)
        {
            return (await repo.GetByAddressAsync(address.Value)).Object;
        }
        else if (!string.IsNullOrEmpty(nickname))
        {
            return (await repo.GetByNicknameAsync(nickname)).Object;
        }
        else
        {
            throw new ArgumentException("Either address or nickname must be provided.");
        }
    }

To set up the database locally, follow the steps below:

  1. Refer to the CONTRIBUTING.md Document:
    Check the CONTRIBUTING.md file in the Mimir repository for detailed setup instructions.

  2. Download Data:
    Download the sample data from this link.

  3. Restore or Import Data:
    Once downloaded, ensure the avatar collection is created in your MongoDB instance and populate it with the provided data. You can use tools like a MongoDB GUI (e.g., Compass) to import the data.

@gagan-bhullar-tech
Copy link
Contributor

@Atralupus can you please assign it to me

@Atralupus
Copy link
Member Author

@Atralupus can you please assign it to me

@gagan-bhullar-tech I assigned you to this issue!


We're now operating Modathon 2024 (Nine Chronicles Hackathon) with a prize pool about $10,000. If you're interested, please take a look at the following items.🙏
https://nine-chronicles.dev/event/2024modathon
https://planetarium.dev/discord

@Atralupus
Copy link
Member Author

You can set up the database locally in a similar way to the comment in this issue.

I've prepared 100 sample avatars and uploaded them here. Feel free to use them if needed!
Download link

@Atralupus Atralupus moved this from No Assignee to Assigned in Planetarium open-source contributor Oct 24, 2024
@gagan-bhullar-tech gagan-bhullar-tech removed their assignment Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No Assignee
Development

No branches or pull requests

2 participants