feat: add timezone support for schedule and user runtime (#282)

This commit is contained in:
Yiming Qi
2026-03-26 01:32:02 +08:00
committed by GitHub
parent 3a7f5200ed
commit 03ba13e7e5
51 changed files with 793 additions and 100 deletions
+2
View File
@@ -17,6 +17,7 @@ CREATE TABLE IF NOT EXISTS users (
role user_role NOT NULL DEFAULT 'member',
display_name TEXT,
avatar_url TEXT,
timezone TEXT NOT NULL DEFAULT 'UTC',
data_root TEXT,
last_login_at TIMESTAMPTZ,
is_active BOOLEAN NOT NULL DEFAULT true,
@@ -156,6 +157,7 @@ CREATE TABLE IF NOT EXISTS bots (
type TEXT NOT NULL,
display_name TEXT,
avatar_url TEXT,
timezone TEXT,
is_active BOOLEAN NOT NULL DEFAULT true,
status TEXT NOT NULL DEFAULT 'ready',
max_context_load_time INTEGER NOT NULL DEFAULT 1440,
@@ -0,0 +1,4 @@
-- 0044_user_timezone
-- Remove the timezone column from users.
ALTER TABLE users DROP COLUMN IF EXISTS timezone;
+4
View File
@@ -0,0 +1,4 @@
-- 0044_user_timezone
-- Add a timezone column to users for user-level timezone preferences.
ALTER TABLE users ADD COLUMN IF NOT EXISTS timezone TEXT NOT NULL DEFAULT 'UTC';
+4
View File
@@ -0,0 +1,4 @@
-- 0045_bot_timezone
-- Remove the optional timezone override from bots.
ALTER TABLE bots DROP COLUMN IF EXISTS timezone;
+4
View File
@@ -0,0 +1,4 @@
-- 0045_bot_timezone
-- Add an optional timezone override to bots.
ALTER TABLE bots ADD COLUMN IF NOT EXISTS timezone TEXT;
+10 -9
View File
@@ -1,15 +1,15 @@
-- name: CreateBot :one
INSERT INTO bots (owner_user_id, display_name, avatar_url, is_active, metadata, status)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING id, owner_user_id, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at;
INSERT INTO bots (owner_user_id, display_name, avatar_url, timezone, is_active, metadata, status)
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id, owner_user_id, display_name, avatar_url, timezone, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at;
-- name: GetBotByID :one
SELECT id, owner_user_id, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, compaction_enabled, compaction_threshold, compaction_model_id, metadata, created_at, updated_at
SELECT id, owner_user_id, display_name, avatar_url, timezone, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, compaction_enabled, compaction_threshold, compaction_model_id, metadata, created_at, updated_at
FROM bots
WHERE id = $1;
-- name: ListBotsByOwner :many
SELECT id, owner_user_id, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
SELECT id, owner_user_id, display_name, avatar_url, timezone, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at
FROM bots
WHERE owner_user_id = $1
ORDER BY created_at DESC;
@@ -18,18 +18,19 @@ ORDER BY created_at DESC;
UPDATE bots
SET display_name = $2,
avatar_url = $3,
is_active = $4,
metadata = $5,
timezone = $4,
is_active = $5,
metadata = $6,
updated_at = now()
WHERE id = $1
RETURNING id, owner_user_id, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at;
RETURNING id, owner_user_id, display_name, avatar_url, timezone, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at;
-- name: UpdateBotOwner :one
UPDATE bots
SET owner_user_id = $2,
updated_at = now()
WHERE id = $1
RETURNING id, owner_user_id, display_name, avatar_url, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at;
RETURNING id, owner_user_id, display_name, avatar_url, timezone, is_active, status, max_context_load_time, max_context_tokens, language, reasoning_enabled, reasoning_effort, chat_model_id, search_provider_id, memory_provider_id, heartbeat_enabled, heartbeat_interval, heartbeat_prompt, metadata, created_at, updated_at;
-- name: UpdateBotStatus :exec
UPDATE bots
+2 -1
View File
@@ -81,7 +81,8 @@ LIMIT sqlc.arg(limit_count);
UPDATE users
SET display_name = $2,
avatar_url = $3,
is_active = $4,
timezone = $4,
is_active = $5,
updated_at = now()
WHERE id = $1
RETURNING *;