Skip to content

Commit 3c70941

Browse files
committed
fix: add OCR hit to frontend search tab
1 parent e2c8ac3 commit 3c70941

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

frontend/index.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,16 @@ <h4 class="font-medium text-gray-800 text-sm truncate" x-text="lec.sub_title ||
431431
<div class="flex items-center justify-between gap-2">
432432
<p class="text-xs text-blue-600 font-medium truncate" x-text="r.course_title"></p>
433433
<span class="text-[10px] uppercase tracking-wide text-gray-400 flex-shrink-0"
434-
x-text="r.hit_field === 'transcript' ? '转录命中'
435-
: r.hit_field === 'sub_title' ? '标题命中'
436-
: '摘要命中'"></span>
434+
x-text="r.hit_field === 'transcript' ? '转录命中'
435+
: r.hit_field === 'sub_title' ? '标题命中'
436+
: r.hit_field === 'ocr' ? 'OCR命中'
437+
: '摘要命中'"></span>
437438
</div>
438439
<h4 class="font-medium text-gray-800 text-sm mt-0.5" x-text="r.sub_title || 'Untitled'"></h4>
439-
<p class="text-xs text-gray-400 mt-1 line-clamp-2"
440-
x-html="highlight(r.hit_field === 'transcript' ? r.transcript : r.summary, searchQuery)"></p>
440+
<p class="text-xs text-gray-400 mt-1 line-clamp-2"
441+
x-html="highlight(r.hit_field === 'transcript' ? r.transcript
442+
: r.hit_field === 'ocr' ? r.ppt_text
443+
: r.summary, searchQuery)"></p>
441444
</button>
442445
</template>
443446
</div>

frontend/js/db.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,22 @@ function _searchSummaries(query) {
173173
const q = query;
174174
return _queryAll(`
175175
SELECT l.sub_id, l.sub_title, l.summary, l.transcript,
176+
(SELECT pp.text FROM ppt_pages pp WHERE pp.sub_id = l.sub_id AND pp.text LIKE '%' || ? || '%' LIMIT 1) AS ppt_text,
176177
l.course_id, c.title AS course_title,
177178
CASE
178179
WHEN l.summary LIKE '%' || ? || '%' THEN 'summary'
179180
WHEN l.sub_title LIKE '%' || ? || '%' THEN 'sub_title'
180181
WHEN l.transcript LIKE '%' || ? || '%' THEN 'transcript'
182+
WHEN EXISTS(SELECT 1 FROM ppt_pages pp2 WHERE pp2.sub_id = l.sub_id AND pp2.text LIKE '%' || ? || '%') THEN 'ocr'
181183
ELSE 'other'
182184
END AS hit_field
183185
FROM lectures l JOIN courses c ON l.course_id = c.course_id
184186
WHERE l.summary LIKE '%' || ? || '%'
185187
OR l.sub_title LIKE '%' || ? || '%'
186188
OR l.transcript LIKE '%' || ? || '%'
189+
OR EXISTS(SELECT 1 FROM ppt_pages pp3 WHERE pp3.sub_id = l.sub_id AND pp3.text LIKE '%' || ? || '%')
187190
ORDER BY l.processed_at DESC LIMIT 50
188-
`, [q, q, q, q, q, q]);
191+
`, [q, q, q, q, q, q, q, q, q]);
189192
}
190193

191194
function _getAllCourses(term) {

0 commit comments

Comments
 (0)