Skip to content

CHAL-95 #done Add a customer_rewards schema#76

Open
Ris345 wants to merge 27 commits into8by8-org:rewardsfrom
Ris345:rewards
Open

CHAL-95 #done Add a customer_rewards schema#76
Ris345 wants to merge 27 commits into8by8-org:rewardsfrom
Ris345:rewards

Conversation

@Ris345
Copy link
Member

@Ris345 Ris345 commented Aug 13, 2025

Checklist

Please ensure you have followed all of the steps below before submitting a pull request:

  • Include the corresponding Jira issue key and #done in the PR title, like so: "JRA-123 #done Migrate Election Reminders"
  • Verify that the code compiles (npm run dev)
  • Verify that the project builds (npm run build:local)
  • Verify that all tests pass
  • Verify that unit tests cover 100% of the code
  • Create Storybook stories for visual components
  • Verify that any visual components match the Figma
  • Test with a screen reader (if applicable)
  • Document your code with TSDoc comments
  • Format your code with Prettier

Overview

REQUIRED
Fill in the overview of this PR, what this PR is trying to achieve.

Test Plan

REQUIRED
What you did to verify your PR works as claimed? Make sure to list things/steps/screenshots/screentcasts so that others can reproduce your test easily. Share styling changes and component updates through screenshots.

Follow ups

It is okay for the PR to be not perfect, list what you/other should work on after this PR is merged.

Ris345 and others added 22 commits January 26, 2025 17:11
This reverts commit 24505e9.
* Welcome file.md created from https://stackedit.io/

* How to set up your development environment.md created from https://stackedit.io/

* Common variables.md created from https://stackedit.io/

* Home.md created from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Home.md updated from https://stackedit.io/

* Added Main Page to wiki.

* Added development environment setup

* Delete CONTRIBUTING.md

* Delete Common variables.md

* Delete Home.md

* Delete How to set up your development environment.md

* Delete STYLE_GUIDE.md

* Delete doc_base.txt

* Delete Welcome file.md

* Update Home.md

made requested changes from PR 8by8-org#73

* Updated and renamed file

added details specified in PR 8by8-org#73

* Update Getting Started.md

* Added Links and other change specified

Added a break to Line 6 and added a few links to the bottom of the page

* Update Home.md

Added table of contents

* Update Home.md

Rearranged table of contents, external links

* Changed Getting Started.md file for updated version provided

* Deleted old Getting Started file
@Ris345 Ris345 requested a review from dvorakjt August 14, 2025 13:01
Copy link
Contributor

@dvorakjt dvorakjt left a comment

Choose a reason for hiding this comment

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

Hi Rishav,

Great work! Just a few minor changes to request. See the comments below for details.

Additionally, we can optimize this further by creating indices on foreign key fields for faster lookup (PostgreSQL doesn't do this automatically). We should also enable RLS and create security policies on these tables. Snapshots should be accessible by any authenticated user and claimed rewards should only be accessible by the referenced user.

Great work so far!

create table claimed_rewards (
id serial primary key,
user_id uuid not null references public.users(id) on delete restrict,
reward_id uuid not null,
Copy link
Contributor

Choose a reason for hiding this comment

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

For the user relation, it makes more sense that the behavior should be on delete cascade. If a user is deleted, all of their claimed_rewards should also be deleted.

reward_updated_at timestamptz not null,
claimed_at timestamptz not null,
foreign key (reward_id, reward_updated_at) references reward_snapshots(id, updated_at) on delete restrict
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, on delete restrict is good because we don't want to be able to delete snapshots unless all claimed rewards that reference them are deleted.


create table vouchers (
id serial primary key,
claimed_reward_id integer not null references claimed_rewards(id) on delete restrict,
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, for this relation, on delete cascade makes more sense. If a claimed reward is deleted, all related vouchers should be deleted, too.

@Ris345
Copy link
Member Author

Ris345 commented Sep 7, 2025

Before I push my new code do you mean enable RLS and indexing for all each table ?

@Ris345 Ris345 requested a review from dvorakjt September 7, 2025 18:03
@dvorakjt
Copy link
Contributor

Yes, that is correct. I'm going to send you an updated ERD document with the latest changes I will need to request based on revisions to the main rewards system schema

dvorakjt and others added 2 commits December 13, 2025 12:11
* upgraded next.js, executed npm audit fix, added react-confetti, supressed irrelevant warnings in test environment

* upgraded jest version, fixed failing tests

* removed dependency on node 18 from github actions test workflow, restored test coverage to 100%

* removed lockfile and reinstalled packages

* regenerated lockfile

* diagnosing breaking tests in CI

* updated node version to latest in test workflow

* attempting to resolve failure of tests in ci environment

* testing without overrides

* attempting to resolve glob issue
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.

3 participants