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(examples/hof): Title and description for realms, sorting by upvotes and newest #3674

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

Ursulovic
Copy link
Contributor

@Ursulovic Ursulovic commented Feb 3, 2025

Title And Description for Hall of Fame realms

Goal

Add title and description to realms in the Hall of Fame, as well as functionality of sorting realms by upvotes and by date of publishing.

Improvements

Title and Description

Realms in Hall of Fame will now have title and description, this will give users more context about each realm.
From now on, people who wish to publish their realm in the Hall of Fame will have to provide a title and description when registering their realm.

Sorting Realms by Upvotes and Newest realms

Realms in the Hall of Fame will now have the functionality to be sorted by upvotes and most recent realms. This will improve user experience by making it easier to find specific realms or explore new ones.

Feature Progress 🔄

  • Title and description functionality
  • Tests for title and description functionality
  • Sorting realms by upvotes and newest realms functionality
  • Tests for sorting realms by upvotes and newest realms functionality

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Feb 3, 2025
@Ursulovic Ursulovic changed the title Improvement(Hall of Fame): Title and Description for Realms feat(Hall of Fame): Title and Description for Realms Feb 3, 2025
@Gno2D2 Gno2D2 requested a review from a team February 3, 2025 13:07
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Feb 3, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🟢 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: Ursulovic/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🟢 Requirement satisfied
└── 🟢 If
    ├── 🟢 Condition
    │   └── 🟢 Or
    │       ├── 🔴 At least 1 user(s) of the organization reviewed the pull request (with state "APPROVED")
    │       ├── 🟢 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🟢 Then
        └── 🟢 Not (🔴 This label is applied to pull request: review/triage-pending)

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)
    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors

@leohhhn leohhhn changed the title feat(Hall of Fame): Title and Description for Realms feat(examples/hof): Title and description for realms Feb 3, 2025
Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@Ursulovic Ursulovic marked this pull request as ready for review February 3, 2025 18:32
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Feb 3, 2025
Comment on lines 105 to 109
func RegisterMetadata(params ...string) Metadata {
// Validate params length
if len(params) != 2 {
panic(ErrInvalidMetadata)
}
Copy link
Contributor

@leohhhn leohhhn Feb 4, 2025

Choose a reason for hiding this comment

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

This is a bad approach, you're using variadic arguments but you know that you will have only two arguments.

Variadic arguments should be used only in specific cases, and this isn't one of them, as you could've done this in a very straighforward manner with two arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed variadic arguments and used 2 arguments instead: 02edc70

exhibition.items.Set(pkgpath, i)
exhibition.itemsSorted.Set(id.String(), i)

std.Emit("Registration")
}

func RegisterMetadata(params ...string) Metadata {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this whole function; Just add the title and description in the Register function directly. Keep the checks, but don't panic but just add an empty return, just like in the rest of the function

Copy link
Contributor

Choose a reason for hiding this comment

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

Imagine how your code will be used; if you need to use Register inside of another realm's code, if you panic, you will fully block execution of the realm that called Register. If you simply do a return, without an error, in Register, HOF will try to add the realm that called it, it may work, but if not, nothing will happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed RegisterMEtadata functon, also replaced panic with return in this commit: 02edc70

upvote *avl.Tree // std.Addr > struct{}{}
downvote *avl.Tree // std.Addr > struct{}{}
}

Metadata struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a reason to have this, just add two strings to the Item type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit: 02edc70

@@ -45,7 +46,7 @@ func (e Exhibition) Render(path string, dashboard bool) string {

out += "<div>\n\n"
id, _ := seqid.FromString(item.Key)
out += ufmt.Sprintf("### Submission #%d\n\n", int(id))
out += md.H3(ufmt.Sprintf("Submission #%d", int(id))) + "\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is a \n needed here? I'm not sure, please double check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this in last commit, markdown is a lot different from this: 02edc70

Comment on lines 62 to 64
out := ""

out += md.CodeBlock(i.pkgpath) + "\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a screenshot of how the new hall of fame page will look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lately I've changed the look of HoF alot, so I don't think this is relevant anymore, but here is screenshot of refactored look:

image

Since we didn't discuss the specifics of a new look, I took the liberty of designing it this way. Let me know if any changes are needed.

Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

You need to change the approach in your implementation; I've left comments.

Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

@Ursulovic

A couple of things, some of which are the fundamentals of collaborating on GitHub:

  1. Please, when someone leaves comments, reply to them properly; ideally you also add the commit in which you fixed what the comment was about.
  2. When you add new functionality somewhere, you also need to write tests to cover that. I tried using the app and clicking the "sort by upvotes", but it just doesn't work.
  3. You need to update the PR title and description to match what's going on in the PR, which isn't the case right now.
  4. When you finish your work on a PR, you need to check the CI, which will tell you if something is wrong (ie the tests fail currently)

Btw; you removed the sorting functionality that the app originally had (sort by latest) and replaced it with the "sort by upvotes". The default sort should be by time of addition, while the other option should be sort by upvotes (most and least). Also, you've changed the datasource impl, and I'm assuming that you didn't check out where it's used - I suggest you keep it the same as before, as someone might be depending on it.

You also made some other mistakes, but we'll get to them once the above is resolved.

This is all a learning process; it's ok that you make mistakes, but I would like to see you put in a bit more time, effort and focus into your work, and not do things last minute & rushed.

@Ursulovic Ursulovic changed the title feat(examples/hof): Title and description for realms feat(examples/hof): Title and description for realms, sorting by upvotes and newest Feb 9, 2025
@Ursulovic Ursulovic closed this Feb 9, 2025
@Ursulovic Ursulovic reopened this Feb 9, 2025
Ivan Ursulovic and others added 2 commits February 10, 2025 01:53
description: "This is a test realm in the Hall of Fame",
blockNum: 42,
upvote: avl.NewTree(),
downvote: avl.NewTree(),
}
item.downvote.Set("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5", struct{}{})
item.upvote.Set("g1w4ek2u33ta047h6lta047h6lta047h6ldvdwpn", struct{}{})
Copy link
Member

Choose a reason for hiding this comment

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

btw @leohhhn; you can consider using p/moul/addrset to make this more efficiently.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Ursulovic Let's switch to p/moul/addrset for managing the number of upvotes/downvotes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@leohhhn Will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented in commit: c576d01

@Gno2D2 Gno2D2 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Feb 11, 2025
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: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants