Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(db): fix bugs based on sqlite date format difference from chrono #1951

Merged
merged 8 commits into from
Apr 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ee/tabby-db/src/user_completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ impl DbConn {
let duration = Duration::from_millis(ts as u64);
let created_at =
DateTime::from_timestamp(duration.as_secs() as i64, duration.subsec_nanos())
.context("Invalid created_at timestamp")?;
.context("Invalid created_at timestamp")?
.as_sqlite_datetime();

let res = query!(
"INSERT INTO user_completions (user_id, completion_id, language, created_at) VALUES (?, ?, ?, ?);",
user_id,
Expand Down Expand Up @@ -109,7 +111,7 @@ impl DbConn {
SUM(selects) as selects,
SUM(views) as views
FROM user_completions JOIN users ON user_id = users.id AND users.active
WHERE user_completions.created_at >= DATE('now', '-1 year')
WHERE user_completions.created_at >= DATETIME('now', '-1 year')
AND ({users_empty} OR user_id IN ({users}))
GROUP BY 1, 2
ORDER BY 1, 2 ASC
Expand Down Expand Up @@ -161,7 +163,7 @@ impl DbConn {
views,
IIF(language IN ({all_languages}), language, 'other') as language
FROM user_completions JOIN users ON user_id = users.id AND users.active
WHERE user_completions.created_at >= ?1 AND user_completions.created_at < ?2
WHERE user_completions.created_at >= ?1 AND user_completions.created_at <= ?2
boxbeam marked this conversation as resolved.
Show resolved Hide resolved
)
WHERE ({no_selected_users} OR user_id IN ({users}))
AND ({no_selected_languages} OR language IN ({languages}))
Expand Down
Loading