Skip to content

Commit

Permalink
feat: add employee activity tracking in the past 30 days (#72)
Browse files Browse the repository at this point in the history
* feat: add employee activity tracking in the past 30 days with society bonus option

* chore: modify column definitions and optimize indexes

* fix: Cased vars, add check for job update and remove job check on player checkout

* refactor: remove society bonus option for now in favor of activity tracking

* fix: replace onGroupUpdate for OnJobUpdate and add foreign key to table

* feat: min duty log time config entry

* feat: minor optimization and added onduty display

* fix(server/main): onduty display false if player offline

* chore: replace all tabs with 4 spaces for consistent indentation

---------

Co-authored-by: Manason <clanerp@gmail.com>
  • Loading branch information
0Programmer and Manason authored Sep 19, 2024
1 parent 32538e7 commit e3a797e
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 94 deletions.
12 changes: 10 additions & 2 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local function findPlayers()
for _, v in pairs(closePlayers) do
v.id = GetPlayerServerId(v.id)
end
return lib.callback.await('qbx_management:server:getPlayers', false, closePlayers)
return lib.callback.await('qbx_management:server:getPlayers', false, closePlayers)
end

-- Presents a menu to manage a specific employee including changing grade or firing them
Expand Down Expand Up @@ -84,13 +84,21 @@ local function employeeList(groupType)
local groupName = QBX.PlayerData[groupType].name
local employees = lib.callback.await('qbx_management:server:getEmployees', false, groupName, groupType)
for _, employee in pairs(employees) do
employeesMenu[#employeesMenu + 1] = {
local employeesData = {
title = employee.name,
description = groupType == 'job' and JOBS[groupName].grades[employee.grade].name or GANGS[groupName].grades[employee.grade].name,
onSelect = function()
manageEmployee(employee, groupName, groupType)
end,
}
if employee.hours and employee.last_checkin then
employeesData.metadata = {
{ label = locale('menu.employee_status'), value = employee.onduty and locale('menu.on_duty') or locale('menu.off_duty') },
{ label = locale('menu.hours_in_days'), value = employee.hours },
{ label = locale('menu.last_checkin'), value = employee.last_checkin },
}
end
employeesMenu[#employeesMenu + 1] = employeesData
end

lib.registerContext({
Expand Down
2 changes: 2 additions & 0 deletions config/server.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
return {
discordWebhook = nil, -- Replace nil with your webhook if you chose to use discord logging over ox_lib logging
minOnDutyLogTimeMinutes = 30,
formatDateTime = '%m-%d-%Y %H:%M',

-- While the config boss menu creation still works, it is recommended to use the runtime export instead.
---@alias GroupName string
Expand Down
4 changes: 3 additions & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ client_scripts {
}

server_scripts {
'@oxmysql/lib/MySQL.lua',
'server/main.lua',
'server/storage.lua',
}

files {
Expand All @@ -27,4 +29,4 @@ files {
}

lua54 'yes'
use_experimental_fxv2_oal 'yes'
use_experimental_fxv2_oal 'yes'
7 changes: 6 additions & 1 deletion locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"gang_menu": "Bande Menu",
"boss_menu": "Boss Menu",
"gang_management": "[E] - Åbn Bande menu",
"boss_management": "[E] - Åbn Boss menu"
"boss_management": "[E] - Åbn Boss menu",
"hours_in_days": "Hours worked in 30 days",
"last_checkin": "Last check in",
"employee_status": "Employee status",
"on_duty": "On Duty",
"off_duty": "Off Duty"
},
"error": {
"cant_promote": "Du kan ikke ændre graden for en person, hvis egen grad er større eller lig med din...",
Expand Down
7 changes: 6 additions & 1 deletion locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"gang_menu": "Gangmenü",
"boss_menu": "Bossmenü",
"gang_management": "[E] - Gangmanagement öffnen",
"boss_management": "[E] - Bossmanagement öffnen"
"boss_management": "[E] - Bossmanagement öffnen",
"hours_in_days": "Hours worked in 30 days",
"last_checkin": "Last check in",
"employee_status": "Employee status",
"on_duty": "On Duty",
"off_duty": "Off Duty"
},
"error": {
"cant_promote": "Du kannst nicht von jemandem den Rang ändern der gleich oder höher ist, als du...",
Expand Down
7 changes: 6 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"gang_menu": "Gang Menu",
"boss_menu": "Boss Menu",
"gang_management": "[E] - Open Gang Management",
"boss_management": "[E] - Open Boss Management"
"boss_management": "[E] - Open Boss Management",
"hours_in_days": "Hours worked in 30 days",
"last_checkin": "Last check in",
"employee_status": "Employee status",
"on_duty": "On Duty",
"off_duty": "Off Duty"
},
"error": {
"cant_promote": "You can't change the grade of a person who's own grade is greater or equal to yours...",
Expand Down
7 changes: 6 additions & 1 deletion locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"gang_menu": "Menú de la Banda",
"boss_menu": "Menú del Jefe",
"gang_management": "[E] - Abrir Gestión de la Banda",
"boss_management": "[E] - Abrir Gestión del Jefe"
"boss_management": "[E] - Abrir Gestión del Jefe",
"hours_in_days": "Hours worked in 30 days",
"last_checkin": "Last check in",
"employee_status": "Employee status",
"on_duty": "On Duty",
"off_duty": "Off Duty"
},
"error": {
"cant_promote": "No puedes cambiar el grado de una persona cuyo grado es mayor o igual al tuyo...",
Expand Down
7 changes: 6 additions & 1 deletion locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"gang_menu": "Menu de Gangue",
"boss_menu": "Menu de Chefia",
"gang_management": "[E] - Abrir Gestão de Gangues",
"boss_management": "[E] - Abrir Gestão de Chefia"
"boss_management": "[E] - Abrir Gestão de Chefia",
"hours_in_days": "Hours worked in 30 days",
"last_checkin": "Last check in",
"employee_status": "Employee status",
"on_duty": "On Duty",
"off_duty": "Off Duty"
},
"error": {
"cant_promote": "Não podes mudar o grau de uma pessoa cujo grau seja maior ou igual ao teu...",
Expand Down
7 changes: 6 additions & 1 deletion locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"gang_menu": "Çete Menüsü",
"boss_menu": "Patron Menüsü",
"gang_management": "[E] - Çete Yönetimini Aç",
"boss_management": "[E] - Patron Yönetimini Aç"
"boss_management": "[E] - Patron Yönetimini Aç",
"hours_in_days": "Hours worked in 30 days",
"last_checkin": "Last check in",
"employee_status": "Employee status",
"on_duty": "On Duty",
"off_duty": "Off Duty"
},
"error": {
"cant_promote": "Kendi rütbeniz eşit veya büyük olan birinin rütbesini değiştiremezsiniz...",
Expand Down
12 changes: 12 additions & 0 deletions qbx_management.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS `player_jobs_activity` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`citizenid` VARCHAR(50) COLLATE utf8mb4_unicode_ci,
`job` varchar(255) NOT NULL,
`last_checkin` int NOT NULL,
`last_checkout` int NULL DEFAULT NULL,
FOREIGN KEY (`citizenid`) REFERENCES `players` (`citizenid`) ON DELETE CASCADE,
PRIMARY KEY (`id`) USING BTREE,
INDEX `id` (`id` DESC) USING BTREE,
INDEX `last_checkout` (`last_checkout` ASC) USING BTREE,
INDEX `citizenid_job` (`citizenid`, `job`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
Loading

0 comments on commit e3a797e

Please sign in to comment.