Skip to content

[EPIC] Efficient Review + Role Level Averaging #136

@banushi-a

Description

@banushi-a

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions