The table containing the KPI values is public.kpi_values_history
. It is actually a historical log of changes made to a
particular KPI and the latest (currently valid) values can be retrieved using
the public.kpi_definitions_with_latest_values
view.
Adding new KPI definition requires adding a new entry in public.kpi_definition
table. KPI definitions can be used by
multiple circles, thus allowing a particular circle to start recording values for this KPI requires inserting a record
to public.circle_kpi_definition
. End users can also propose new KPIs from the UI - doing so will create the required entries but in
order to be usable from the UI they need the flag public.kpi_definition.is_approved
to be set to true.
Onboarding a new user requires creating his account in the Supabase dashboard and creating an entry in public.kpi_user
that references the newly created row in auth.users
. Assigning a user to a circle is done by adding a row in public.circle_user
.
Stores user information in relation to KPIs.
Represents groups or teams within the organisation.
Maps circles to KPI definitions.
Associates users with circles.
Stores definitions of KPIs.
Stores historical KPI values.
Sets target values for KPIs.
Logs historical actions on targets.
Update timestamp in updated_at
column automatically in table kpi_definition.
Update timestamp in updated_at
column automatically in table circle.
Update timestamp in updated_at
column automatically in table kpi_user.
Update timestamp in updated_at
column automatically in table target.
Check if the value entered in table kpi_values_history is valid in corresponds with the defined unit.
- if unit is boolean: value has to be 0 or 1
- if unit is percentage (%): value has to be >= 0
- if unit is numeric: value has to be >= 0
Check if a user has set a default circle. A user is only allowed one default circle.
The action
column in target_history is automatically set depending on the action (insert/ update/ delete) that is performed.