Skip to content

Commit 490aaed

Browse files
committed
fix: update activity log types to use agent prefixes for consistency
1 parent 87361e5 commit 490aaed

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

frontend/src/composables/useActivityLogFilters.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ export function useActivityLogFilters () {
1616
type: FIELD_TYPE.SELECT,
1717
operators: FIELD_OPERATORS.SELECT,
1818
options: [{
19-
label: 'Login',
20-
value: 'login'
19+
label: 'User login',
20+
value: 'agent_login'
2121
}, {
22-
label: 'Logout',
23-
value: 'logout'
22+
label: 'User logout',
23+
value: 'agent_logout'
2424
}, {
25-
label: 'Away',
26-
value: 'away'
25+
label: 'User away',
26+
value: 'agent_away'
2727
}, {
28-
label: 'Away Reassigned',
29-
value: 'away_reassigned'
28+
label: 'User away reassigned',
29+
value: 'agent_away_reassigned'
3030
}, {
31-
label: 'Online',
32-
value: 'online'
31+
label: 'User online',
32+
value: 'agent_online'
3333
}]
3434
},
3535
}))

internal/activity_log/activity_log.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (m *Manager) Create(activityType, activityDescription string, actorID int,
9595
// Login records a login event for the given user.
9696
func (al *Manager) Login(userID int, email, ip string) error {
9797
return al.Create(
98-
models.Login,
98+
models.AgentLogin,
9999
fmt.Sprintf("%s (#%d) logged in", email, userID),
100100
userID,
101101
umodels.UserModel,
@@ -107,7 +107,7 @@ func (al *Manager) Login(userID int, email, ip string) error {
107107
// Logout records a logout event for the given user.
108108
func (al *Manager) Logout(userID int, email, ip string) error {
109109
return al.Create(
110-
models.Logout,
110+
models.AgentLogout,
111111
fmt.Sprintf("%s (#%d) logged out", email, userID),
112112
userID,
113113
umodels.UserModel,
@@ -125,7 +125,7 @@ func (al *Manager) Away(actorID int, actorEmail, ip string, targetID int, target
125125
description = fmt.Sprintf("%s (#%d) is away", actorEmail, actorID)
126126
}
127127
return al.Create(
128-
models.Away, /* activity type*/
128+
models.AgentAway, /* activity type*/
129129
description,
130130
actorID, /*actor_id*/
131131
umodels.UserModel, /*target_model_type*/
@@ -143,7 +143,7 @@ func (al *Manager) AwayReassigned(actorID int, actorEmail, ip string, targetID i
143143
description = fmt.Sprintf("%s (#%d) is away and reassigning", actorEmail, actorID)
144144
}
145145
return al.Create(
146-
models.AwayReassigned, /* activity type*/
146+
models.AgentAwayReassigned, /* activity type*/
147147
description,
148148
actorID, /*actor_id*/
149149
umodels.UserModel, /*target_model_type*/
@@ -161,7 +161,7 @@ func (al *Manager) Online(actorID int, actorEmail, ip string, targetID int, targ
161161
description = fmt.Sprintf("%s (#%d) is online", actorEmail, actorID)
162162
}
163163
return al.Create(
164-
models.Online, /* activity type*/
164+
models.AgentOnline, /* activity type*/
165165
description,
166166
actorID, /*actor_id*/
167167
umodels.UserModel, /*target_model_type*/

internal/activity_log/models/models.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import (
55
)
66

77
const (
8-
Login = "login"
9-
Logout = "logout"
10-
Away = "away"
11-
AwayManual = "away_manual"
12-
AwayReassigned = "away_reassigned"
13-
Online = "online"
8+
AgentLogin = "agent_login"
9+
AgentLogout = "agent_logout"
10+
AgentAway = "agent_away"
11+
AgentAwayReassigned = "agent_away_reassigned"
12+
AgentOnline = "agent_online"
1413
)
1514

1615
type ActivityLog struct {

internal/migrations/v0.6.0.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func V0_6_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
167167
IF NOT EXISTS (
168168
SELECT 1 FROM pg_type WHERE typname = 'activity_log_type'
169169
) THEN
170-
CREATE TYPE activity_log_type AS ENUM ('login', 'logout', 'away', 'away_reassigned', 'online');
170+
CREATE TYPE activity_log_type AS ENUM ('agent_login', 'agent_logout', 'agent_away', 'agent_away_reassigned', 'agent_online');
171171
END IF;
172172
END
173173
$$;
@@ -191,6 +191,7 @@ func V0_6_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
191191
);
192192
CREATE INDEX IF NOT EXISTS index_activity_logs_on_actor_id ON activity_logs (actor_id);
193193
CREATE INDEX IF NOT EXISTS index_activity_logs_on_activity_type ON activity_logs (activity_type);
194+
CREATE INDEX IF NOT EXISTS index_activity_logs_on_created_at ON activity_logs (created_at);
194195
`)
195196
if err != nil {
196197
return err

schema.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ DROP TYPE IF EXISTS "user_availability_status" CASCADE; CREATE TYPE "user_availa
1717
DROP TYPE IF EXISTS "applied_sla_status" CASCADE; CREATE TYPE "applied_sla_status" AS ENUM ('pending', 'breached', 'met', 'partially_met');
1818
DROP TYPE IF EXISTS "sla_metric" CASCADE; CREATE TYPE "sla_metric" AS ENUM ('first_response', 'resolution');
1919
DROP TYPE IF EXISTS "sla_notification_type" CASCADE; CREATE TYPE "sla_notification_type" AS ENUM ('warning', 'breach');
20-
DROP TYPE IF EXISTS "activity_log_type" CASCADE; CREATE TYPE "activity_log_type" AS ENUM ('login', 'logout', 'away', 'away_reassigned', 'online');
20+
DROP TYPE IF EXISTS "activity_log_type" CASCADE; CREATE TYPE "activity_log_type" AS ENUM ('agent_login', 'agent_logout', 'agent_away', 'agent_away_reassigned', 'agent_online');
2121

2222
-- Sequence to generate reference number for conversations.
2323
DROP SEQUENCE IF EXISTS conversation_reference_number_sequence; CREATE SEQUENCE conversation_reference_number_sequence START 100;
@@ -546,6 +546,7 @@ CREATE TABLE activity_logs (
546546
);
547547
CREATE INDEX IF NOT EXISTS index_activity_logs_on_actor_id ON activity_logs (actor_id);
548548
CREATE INDEX IF NOT EXISTS index_activity_logs_on_activity_type ON activity_logs (activity_type);
549+
CREATE INDEX IF NOT EXISTS index_activity_logs_on_created_at ON activity_logs (created_at);
549550

550551
INSERT INTO ai_providers
551552
("name", provider, config, is_default)

0 commit comments

Comments
 (0)