Doc text from media async - #270
Merged
ledsun merged 8 commits intoJul 23, 2026
Merged
Conversation
Tamada-Arino
force-pushed
the
doc-text-from-media-async
branch
2 times, most recently
from
July 23, 2026 00:17
503a9e0 to
70a59d5
Compare
…t_from_media is set
Keep the async job's name consistent with DocGenerationsController and the DocGenerationFromMedia service it delegates to.
…controller The job already records raised errors as job messages via UseJobRecordConcern, so the throwaway DocGenerationFromMedia instance built only to call validate_medium! before enqueuing was redundant.
… finished yet The message said "Doc created" before the job actually ran, which was misleading since the doc doesn't exist until the async job completes. Also drop the unused text_generation_pending key.
Tamada-Arino
force-pushed
the
doc-text-from-media-async
branch
from
July 23, 2026 00:56
673e862 to
522a35c
Compare
Matches the existing per-project job cap used elsewhere (docs_controller, projects_controller, annotations_controller, evaluations_controller) to prevent unbounded job queueing.
Contributor
There was a problem hiding this comment.
Pull request overview
Asynchronously generates a Doc’s text from an attached image medium by enqueuing a background job (Ollama + moondream via ImageCaptionService), aligning this workflow with the app’s existing Job-record tracking and enforcing a 10-jobs-per-project cap.
Changes:
- Switch
DocGenerationsController#createfrom synchronous Doc creation to enqueuingDocGenerationFromMediaJoband returning a “started” notice. - Add
DocGenerationFromMediaJob(tracked viaUseJobRecordConcern) and a focused job spec. - Update request specs and i18n strings to reflect async behavior and job-limit enforcement.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/requests/doc_generations_spec.rb | Updates request coverage for async enqueue/run behavior, error recording on jobs, and 10-job limit behavior. |
| spec/jobs/doc_generation_from_media_job_spec.rb | Adds unit coverage ensuring the job delegates to DocGenerationFromMedia and exposes a human-readable job name. |
| config/locales/ja.yml | Adds a localized “text generation started” notice for the async flow. |
| config/locales/en.yml | Adds the English “text generation started” notice for the async flow. |
| app/jobs/doc_generation_from_media_job.rb | Introduces the new background job wired into the Job-record tracking concern. |
| app/controllers/doc_generations_controller.rb | Enqueues the job instead of creating the Doc synchronously; adjusts HTML/JSON responses accordingly and enforces the 10-job limit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
19
to
22
| respond_to do |format| | ||
| format.html { redirect_to show_project_sourcedb_sourceid_docs_path(@project.name, @doc.sourcedb, @doc.sourceid), notice: t('controllers.shared.successfully_created', model: t('activerecord.models.doc')) } | ||
| format.json { render json: @doc.to_hash, status: :created, location: @doc } | ||
| format.html { redirect_to project_docs_path(@project.name), notice: notice } | ||
| format.json { render json: { message: notice, job_name: active_job.job_name }, status: :accepted } | ||
| end |
Collaborator
Author
There was a problem hiding this comment.
The 202 response previously gave clients no way to correlate the request with the enqueued job. Follows the existing pattern in DocsController#add_from_upload: look up the Job record by active_job_id and expose its show URL for polling/log correlation.
ledsun
approved these changes
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Ollama + moondreamを使用して画像からテキストを生成させ、Docのtextに加える一連の処理を非同期化しました。
他のJobと同じく10件以上Jobを登録できないようにしています。
動作確認