Skip to content

feat: add upvote functionality for learning paths#193

Open
sebmuehlbauer wants to merge 1 commit intofnplus:masterfrom
sebmuehlbauer:pangea/fix-issue-20
Open

feat: add upvote functionality for learning paths#193
sebmuehlbauer wants to merge 1 commit intofnplus:masterfrom
sebmuehlbauer:pangea/fix-issue-20

Conversation

@sebmuehlbauer
Copy link
Copy Markdown

Fixes #20

This PR introduces an UpvoteButton component that allows authenticated users to upvote learning paths.

  • Uses Apollo Client mutation to update the upvoted_by field (JSON/Array storage) in the database.
  • Provides feedback to the user via Ant Design messages.
  • Integrates with the existing GraphQL schema to manage user upvotes for better recommendation tracking.

This PR was autonomously generated by Pangea 3 β€” an AI-powered development system.

@xlogix
Copy link
Copy Markdown
Member

xlogix commented Mar 10, 2026

@codex Review this PR

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9efaab966

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


const UPVOTE_PATH = gql`
mutation UpvotePath($pathId: Int!, $userId: String!) {
update_learning_path_by_pk(pk_columns: {id: $pathId}, _append: {voted_by: [ $userId ]}) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Target the correct Hasura mutation and vote storage model

This mutation uses update_learning_path_by_pk with _append on voted_by, but the rest of this codebase consistently targets Learning_Paths plus a separate votes relation (for example, src/components/EditPath/editPath.js mutates update_Learning_Paths and src/pages/search.js reads votes/votes_aggregate), so this operation does not match the existing schema shape and upvote requests will fail at runtime when invoked.

Useful? React with πŸ‘Β / πŸ‘Ž.

Comment on lines +20 to +21
if (votedBy.includes(userId)) {
message.info('You have already upvoted this path!');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Block repeated upvotes until local vote state is refreshed

The duplicate guard checks only the incoming votedBy prop, but this component never updates local state after a successful mutation; if the user clicks again before parent data refreshes, the check still passes and another upvote mutation is sent, which can record duplicate votes for the same user and inflate counts.

Useful? React with πŸ‘Β / πŸ‘Ž.

@xlogix
Copy link
Copy Markdown
Member

xlogix commented Mar 10, 2026

@sebmuehlbauer Please check these review comments and see if the PR needs any changes

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to Upvote a learning path & Update the vote counter on Db

2 participants