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

[EPIC] Efficient Review + Role Level Averaging #136

Open
banushi-a opened this issue Feb 20, 2025 · 0 comments
Open

[EPIC] Efficient Review + Role Level Averaging #136

banushi-a opened this issue Feb 20, 2025 · 0 comments
Assignees

Comments

@banushi-a
Copy link
Contributor

In it's current form, the frontend fetches all reviews per job and computes the average on render [side eye embarrassed emoji]. As half of cooper was at the beginning of the semester, this is an artifact of me creating some usable prototype for our first showcase.

We will move forward by storing the average / total statistics in the database.

For example, if we want to show the average overall rating for a job, we will keep a "running average" in the Roles table.

The first subtask of this epic is to update the database schema. We want to keep running averages for the Roles and Companies tables. Take a look at the schema for Reviews and see what values are added when somebody creates a Review. These will be precisely the ones we add to the Roles and Companies tables.

The next subtask of this epic is to update these new values in the Roles and Companies tables when Reviews are 1) Added, 2) Updated, and 3) Deleted. We will need to update all three at once. One way we can ensure they are all added at once are using drizzle transactions. These operate on an "all or nothing" basis, so we can make sure the actual review averages and the values stored in the Roles and Companies tables stay in sync.
When we do this we will most likely need to wipe the database of all its reviews to make sure the running averages are actually in-line with the actual review averages.

Conditions of Satisfaction:

  1. Schema captures all necessary 'aggregatable' data
  2. API updates all three tables at once xor all fail at once
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

No branches or pull requests

2 participants