Compare commits

..

No commits in common. "a6e29d81ef6fca61ca47d885e2a1aeb25a68271c" and "fb159779241ba419eabbe4416b72bb5b6d999760" have entirely different histories.

2 changed files with 4 additions and 12 deletions

View File

@ -4,7 +4,6 @@ import sqlite3
SEARCH_DB_NAME = 'search.db'
ACCESS_LOG_DB_NAME = 'access_log.db'
FOLDER_CONFIG = 'folder_permission_config.json'
# Connect to the search database.
search_db = sqlite3.connect(SEARCH_DB_NAME, check_same_thread=False)
@ -70,7 +69,7 @@ def updatefileindex():
cursor = search_db.cursor()
# Load folder configuration from JSON file.
with open(FOLDER_CONFIG, "r", encoding="utf-8") as f:
with open("folder_config.json", "r", encoding="utf-8") as f:
config_data = json.load(f)
# Process each configured base folder.

View File

@ -1,7 +1,6 @@
import sqlite3
from flask import Flask, render_template, request, request, jsonify, session
import os
import random
app = Flask(__name__)
@ -40,14 +39,10 @@ def searchcommand():
sql = "SELECT * FROM files"
if conditions:
sql += " WHERE " + " AND ".join(conditions)
sql += " ORDER BY hitcount DESC"
cursor.execute(sql, params)
raw_results = cursor.fetchall()
results = [dict(row) for row in raw_results]
# Randomize the list before sorting to break ties randomly.
random.shuffle(results)
results.sort(key=lambda x: x["hitcount"], reverse=True)
else:
# Advanced search: include transcript. Count transcript hits.
@ -79,11 +74,9 @@ def searchcommand():
transcript = result.get("transcript") or ""
total_hits = sum(transcript.lower().count(word.lower()) for word in words)
result["transcript_hits"] = total_hits
result.pop("transcript", None)
result.pop("transcript")
results.append(result)
# Randomize the list before sorting to break ties randomly.
random.shuffle(results)
# Sort so that files with more transcript hits appear first
results.sort(key=lambda x: x["transcript_hits"], reverse=True)
results = results[:100]