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

feat: In r/demo/users, add ListUsersByPrefix #1708

Merged

Conversation

jefft0
Copy link
Contributor

@jefft0 jefft0 commented Feb 29, 2024

GnoSocial uses r/demo/users to register users. A typical social app can search for other users by name, which requires a search box with partial match. The private variable name2User is an avl.Tree where the key is the user name, and avl.Tree Iterate can already iterate by start and end values. This PR has 2 commits:

  1. Add a new package p/demo/avlhelpers with the function ListByteStringKeysByPrefix . Also add tests.
  2. Use this in r/demo/users to add ListUsersByPrefix to return a list of user names starting from the given prefix.

For example, ListUsersByPrefix("g", 2) returns a list of 2 names with the prefix "g":

["george", "gnofan"]

In the GnoSocial demo app, we plan to use this in a search box.

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@jefft0 jefft0 requested review from a team as code owners February 29, 2024 12:48
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Feb 29, 2024
Copy link

codecov bot commented Feb 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.21%. Comparing base (651f5aa) to head (21f574c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1708      +/-   ##
==========================================
- Coverage   60.22%   60.21%   -0.01%     
==========================================
  Files         562      562              
  Lines       75038    75038              
==========================================
- Hits        45188    45182       -6     
- Misses      26476    26479       +3     
- Partials     3374     3377       +3     
Flag Coverage Δ
contribs/gnodev 61.40% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (-0.86%) ⬇️
gno.land 64.57% <ø> (ø)
gnovm 64.33% <ø> (ø)
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (ø)
tm2 62.02% <ø> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jefft0 jefft0 marked this pull request as draft March 1, 2024 09:57
@jefft0
Copy link
Contributor Author

jefft0 commented Mar 1, 2024

Converted this PR to Draft while addressing the above comments and refactoring some functionality to p/demo/avlhelpers

@jefft0 jefft0 force-pushed the feat/add-ListUsersByPrefix-to-demo-users branch from 516a99d to fe81f9c Compare March 6, 2024 16:45
@jefft0 jefft0 marked this pull request as ready for review March 6, 2024 16:57
@jefft0 jefft0 marked this pull request as draft March 6, 2024 17:07
@jefft0 jefft0 force-pushed the feat/add-ListUsersByPrefix-to-demo-users branch from fe81f9c to 1c6ae24 Compare March 6, 2024 17:14
@jefft0 jefft0 force-pushed the feat/add-ListUsersByPrefix-to-demo-users branch from 1c6ae24 to 04b8e70 Compare March 6, 2024 17:21
@jefft0 jefft0 force-pushed the feat/add-ListUsersByPrefix-to-demo-users branch from 04b8e70 to 19d9215 Compare March 6, 2024 17:24
@jefft0
Copy link
Contributor Author

jefft0 commented Mar 6, 2024

Finished updating the commits and PR description. Ready for review.

@zivkovicmilos
Copy link
Member

Hey @jefft0, can you please merge in the latest master changes? 🙏

@jefft0
Copy link
Contributor Author

jefft0 commented Jun 12, 2024

Hey @jefft0, can you please merge in the latest master changes? 🙏

Done.

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feature 🙏

I left a comment concerning whether we want support for non-ASCII characters in the prefix

examples/gno.land/p/demo/avlhelpers/z_0_filetest.gno Outdated Show resolved Hide resolved
@zivkovicmilos
Copy link
Member

@jefft0 can you please resolve the conflict in the PR, so we can merge? 🙏

@jefft0
Copy link
Contributor Author

jefft0 commented Aug 19, 2024

@jefft0 can you please resolve the conflict in the PR, so we can merge? 🙏

Hi @zivkovicmilos . I resolved the conflict. (Since I opened this PR, the master branch merged a file z_11_filetest.gno . So I just renamed my file to z_12_filetest.gno .)

@jefft0
Copy link
Contributor Author

jefft0 commented Aug 19, 2024

Since I opened this PR, r/demo/users is now pre-loaded with namespace names. So I updated z_12_filetest.gno to use a different test name that doesn't conflict. The test passes again.

@zivkovicmilos zivkovicmilos merged commit e5c1152 into gnolang:master Aug 28, 2024
119 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants