Skip to content

Add SQLite database for translation history#2

Merged
jdfalk merged 1 commit intomainfrom
zyuwb2-codex/develop-golang-project-with-specified-features
Jun 6, 2025
Merged

Add SQLite database for translation history#2
jdfalk merged 1 commit intomainfrom
zyuwb2-codex/develop-golang-project-with-specified-features

Conversation

@jdfalk
Copy link
Copy Markdown
Owner

@jdfalk jdfalk commented Jun 6, 2025

Summary

  • track translated subtitles in an SQLite database
  • expose history command for viewing records
  • record translations automatically
  • add --db option and defaults in config

Testing

  • go vet ./...
  • go build ./...
  • go test ./...

https://chatgpt.com/codex/tasks/task_e_684309f9d9608321906671a4e5ff20e1

@jdfalk jdfalk added the codex Created or modified by AI/automation agents label Jun 6, 2025 — with ChatGPT Codex Connector
@jdfalk jdfalk requested a review from Copilot June 6, 2025 16:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an SQLite database to track translation history and introduces a new history command to view previous translation records while also enhancing the translate command to record translations automatically.

  • Adds database functionality including schema initialization, insert, and listing capabilities.
  • Implements and tests translation functions using both Google Translate and ChatGPT.
  • Updates CLI commands (translate, history, merge, convert) and configuration to support the new history tracking feature.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/translator/translator_test.go Adds tests for GoogleTranslate and unsupported errors.
pkg/translator/translator.go Implements translation functions using external APIs.
pkg/logging/logging.go Provides logger initialization and per-component configuration.
pkg/database/database_test.go Tests for database insert and listing functionality.
pkg/database/database.go Introduces SQLite schema and functions for subtitles.
main.go Sets up the application entry point.
go.mod Updates module dependencies and settings.
cmd/translate.go Enhances translate command to include DB record insertion.
cmd/root.go Configures CLI root commands and initializes configuration.
cmd/merge.go Provides merge command to combine subtitles.
cmd/history.go Adds new history command to display translation records.
cmd/convert.go Provides subtitle conversion command.
README.md Updates documentation to reflect new features.

Comment thread cmd/translate.go
}
if dbPath := viper.GetString("db_path"); dbPath != "" {
if db, err := database.Open(dbPath); err == nil {
_ = database.InsertSubtitle(db, in, lang, service)
Copy link

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider handling or logging the error returned from InsertSubtitle instead of silently discarding it, so that potential database write issues can be surfaced.

Suggested change
_ = database.InsertSubtitle(db, in, lang, service)
if err := database.InsertSubtitle(db, in, lang, service); err != nil {
logger.Warnf("InsertSubtitle failed: %v", err)
}

Copilot uses AI. Check for mistakes.
@jdfalk jdfalk force-pushed the zyuwb2-codex/develop-golang-project-with-specified-features branch from ec73180 to d9f63ee Compare June 6, 2025 22:48
@jdfalk jdfalk merged commit a951561 into main Jun 6, 2025
@jdfalk jdfalk deleted the zyuwb2-codex/develop-golang-project-with-specified-features branch June 6, 2025 22:49
@github-actions
Copy link
Copy Markdown
Contributor

Issue closed via automated workflow.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 3, 2025

Issue closed via automated workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex Created or modified by AI/automation agents

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants