From f9a72ba2ace0a1b82b3cf2adfa8ced5473e61eb0 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Tue, 29 Jul 2025 12:51:42 +0200 Subject: [PATCH] Add info into database to track api or token usage --- htdocs/install/mysql/migration/22.0.0-23.0.0.sql | 6 ++++++ htdocs/install/mysql/tables/llx_oauth_token.sql | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/22.0.0-23.0.0.sql b/htdocs/install/mysql/migration/22.0.0-23.0.0.sql index 2a3c75a5322..653663ddb58 100644 --- a/htdocs/install/mysql/migration/22.0.0-23.0.0.sql +++ b/htdocs/install/mysql/migration/22.0.0-23.0.0.sql @@ -49,4 +49,10 @@ ALTER TABLE llx_commande ADD COLUMN user_agent varchar(255); ALTER TABLE llx_c_currencies ADD COLUMN max_decimal_unit tinyint NULL; -- Number of decimal in this currency for unit prices ALTER TABLE llx_c_currencies ADD COLUMN max_decimal_tot tinyint NULL; -- Number of decimal in this currency for total prices +ALTER TABLE llx_oauth_token ADD COLUMN lastaccess datetime NULL; -- updated at each api access +ALTER TABLE llx_oauth_token ADD COLUMN apicount_previous_month BIGINT UNSIGNED DEFAULT 0; +ALTER TABLE llx_oauth_token ADD COLUMN apicount_month BIGINT UNSIGNED DEFAULT 0; -- increased by 1 at each page access, saved into pageviews_previous_month when on different month than lastaccess +ALTER TABLE llx_oauth_token ADD COLUMN apicount_total BIGINT UNSIGNED DEFAULT 0; -- increased by 1 at each page access, no reset + + -- end of migration diff --git a/htdocs/install/mysql/tables/llx_oauth_token.sql b/htdocs/install/mysql/tables/llx_oauth_token.sql index 95e68764fd0..21b777ea67c 100644 --- a/htdocs/install/mysql/tables/llx_oauth_token.sql +++ b/htdocs/install/mysql/tables/llx_oauth_token.sql @@ -27,5 +27,9 @@ CREATE TABLE llx_oauth_token ( restricted_ips varchar(200), -- Restrict the authentication mode/token to some IPs datec datetime DEFAULT NULL, -- date creation project tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - entity integer DEFAULT 1 + entity integer DEFAULT 1, + lastaccess datetime NULL, -- updated at each api access + apicount_previous_month BIGINT UNSIGNED DEFAULT 0, + apicount_month BIGINT UNSIGNED DEFAULT 0, -- increased by 1 at each page access, saved into pageviews_previous_month when on different month than lastaccess + apicount_total BIGINT UNSIGNED DEFAULT 0 -- increased by 1 at each page access, no reset )ENGINE=innodb;