-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add layer 0 operational insights page w/ charts for user data
- Loading branch information
Showing
17 changed files
with
533 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
CREATE TABLE public.login_metrics ( | ||
user_id INTEGER NOT NULL PRIMARY KEY, | ||
total BIGINT NOT NULL DEFAULT 1, | ||
last_login timestamp with time zone DEFAULT now(), | ||
FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
CREATE INDEX user_login_metrics_user_id_idx ON public.login_metrics(user_id); | ||
CREATE INDEX user_login_metrics_login_count_idx ON public.login_metrics(total); | ||
CREATE INDEX user_login_metrics_last_login_idx ON public.login_metrics(last_login); | ||
|
||
CREATE TABLE public.login_activity ( | ||
time_interval TIMESTAMP NOT NULL, | ||
facility_id INT, | ||
total_logins BIGINT DEFAULT 1, | ||
FOREIGN KEY (facility_id) REFERENCES public.facilities(id) ON DELETE CASCADE ON UPDATE CASCADE, | ||
PRIMARY KEY (time_interval, facility_id) | ||
); | ||
CREATE INDEX login_activity_time_interval_idx ON public.login_activity(time_interval); | ||
CREATE INDEX login_activity_facility_id_idx ON public.login_activity(facility_id); | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
DROP TABLE public.login_metrics CASCADE; | ||
DROP TABLE public.login_activity CASCADE; | ||
-- +goose StatementEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package models | ||
|
||
import "time" | ||
|
||
type LoginMetrics struct { | ||
UserID uint `json:"user_id" gorm:"primaryKey"` | ||
Total int64 `json:"total" gorm:"default:1"` | ||
LastLogin time.Time `json:"last_login" gorm:"default:CURRENT_TIMESTAMP"` | ||
|
||
User *User `json:"user,omitempty" gorm:"foreignKey:UserID;constraint:OnDelete CASCADE"` | ||
} | ||
|
||
func (LoginMetrics) TableName() string { return "login_metrics" } | ||
|
||
type LoginActivity struct { | ||
TimeInterval time.Time `json:"time_interval" gorm:"primaryKey"` | ||
FacilityID uint `json:"facility_id" gorm:"primaryKey"` | ||
TotalLogins int64 `json:"total_logins" gorm:"default:1"` | ||
|
||
Facility *Facility `json:"facility,omitempty" gorm:"foreignKey:FacilityID;constraint:OnDelete CASCADE"` | ||
} | ||
|
||
func (LoginActivity) TableName() string { return "login_activity" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.