diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d9057e..7dabe63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Не выпущено +- Backend `0.11.1` и frontend `0.1.1`: в управлении пользователями показываются даты первого и последнего входа, а также последнего сброса пароля. - Backend `0.11.0` и frontend `0.1.0`: лаборатория переоформлена по дизайн-системе «Түндүк»; добавлены учетные записи, обязательная смена временного пароля, личный кабинет и управление пользователями для `admin`. - Backend обновлён до `0.10.4`: многословный поиск получил низковесный OR fallback с требованием совпадения минимум двух терминов; fallback пропускает распознанные названия нормативных актов. - Backend обновлён до `0.10.3`: запрос о налоге на прибыль поднимает действующий diff --git a/README.md b/README.md index 3860fa0..74f0693 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Telegram-бот — только часть рабочего окружения ## Текущее состояние Сейчас реализованы Telegram-бот-секретарь версии `0.2.2`, backend версии -`0.11.0` и внутренний frontend лаборатории `0.1.0`. Авторизация хранится в +`0.11.1` и внутренний frontend лаборатории `0.1.1`. Авторизация хранится в SQLite; первый пользователь `admin` создаётся интерактивной CLI-командой. Поиск расширяет аббревиатуры организационно-правовых форм и поднимает действующий Налоговый кодекс для запросов о налоге на прибыль. @@ -18,8 +18,8 @@ SQLite; первый пользователь `admin` создаётся инт | Компонент | Версия | Состояние | |---|---:|---| | Telegram-бот | `0.2.2` | на Synology работает `0.2.1`; обновление после слияния | -| Backend | `0.11.0` | авторизация и поиск с фильтрами; тематический поиск ОсОО/ЖЧК | -| Frontend | `0.1.0` | лаборатория поиска, личный кабинет и управление учетными записями | +| Backend | `0.11.1` | авторизация и поиск с фильтрами; тематический поиск ОсОО/ЖЧК | +| Frontend | `0.1.1` | лаборатория поиска, личный кабинет и управление учетными записями | | Сбор и обработка правовых данных | `0.8.0` | добавлены relevance set и оценка выдачи | | RAG и база знаний | — | ещё не созданы | @@ -62,4 +62,4 @@ python3 -m unittest discover -s tools/telegram-bot -v --- -Акылдаш · Telegram-бот v0.2.2 · Backend v0.11.0 · Frontend v0.1.0 +Акылдаш · Telegram-бот v0.2.2 · Backend v0.11.1 · Frontend v0.1.1 diff --git a/backend/README.md b/backend/README.md index 86f455b..30ef29f 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,6 +1,6 @@ # Backend Акылдаш -Версия: `0.11.0` +Версия: `0.11.1` Первая backend-область проекта — загрузка правовых документов из официального Open Data API ЦБД Минюста Кыргызской Республики. Код расположен в @@ -253,4 +253,4 @@ PYTHONPATH=backend python3 -m search.query "ЖЧК ачуу тартиби" --la --- -Акылдаш · Backend v0.11.0 · Frontend v0.1.0 +Акылдаш · Backend v0.11.1 · Frontend v0.1.1 diff --git a/backend/ingestion/minjust_cbd.py b/backend/ingestion/minjust_cbd.py index 5f177c1..caa16d0 100644 --- a/backend/ingestion/minjust_cbd.py +++ b/backend/ingestion/minjust_cbd.py @@ -364,7 +364,7 @@ def main() -> int: print( f"discovered={result.discovered} downloaded={result.downloaded} " f"skipped={result.skipped} failed={result.failed}\n" - f"Akyldash · Backend v{APP_VERSION} · Frontend v0.1.0" + f"Akyldash · Backend v{APP_VERSION} · Frontend v0.1.1" ) return int(result.failed > 0) diff --git a/backend/normalization/minjust_cbd.py b/backend/normalization/minjust_cbd.py index 84a195c..5cdcc35 100644 --- a/backend/normalization/minjust_cbd.py +++ b/backend/normalization/minjust_cbd.py @@ -720,7 +720,7 @@ def main() -> int: print( f"discovered={result.discovered} normalized={result.normalized} " f"skipped={result.skipped} failed={result.failed}\n" - f"Akyldash · Backend v{APP_VERSION} · Frontend v0.1.0" + f"Akyldash · Backend v{APP_VERSION} · Frontend v0.1.1" ) return int(result.failed > 0) diff --git a/backend/search/auth.py b/backend/search/auth.py index 3b6611f..fc113e6 100644 --- a/backend/search/auth.py +++ b/backend/search/auth.py @@ -41,7 +41,10 @@ class AuthStore: password_hash BLOB NOT NULL, password_salt BLOB NOT NULL, must_change_password INTEGER NOT NULL DEFAULT 1, - created_at INTEGER NOT NULL + created_at INTEGER NOT NULL, + first_login_at INTEGER, + last_login_at INTEGER, + password_reset_at INTEGER ); CREATE TABLE IF NOT EXISTS sessions ( token_hash BLOB PRIMARY KEY, @@ -49,6 +52,10 @@ class AuthStore: expires_at INTEGER NOT NULL ); """) + user_columns = {row["name"] for row in self.connection.execute("PRAGMA table_info(users)")} + for column in ("first_login_at", "last_login_at", "password_reset_at"): + if column not in user_columns: + self.connection.execute(f"ALTER TABLE users ADD COLUMN {column} INTEGER") self.connection.execute("PRAGMA foreign_keys = ON") self.connection.commit() @@ -92,7 +99,9 @@ class AuthStore: now = int(time.time()) self.connection.execute("DELETE FROM sessions WHERE expires_at <= ?", (now,)) self.connection.execute("INSERT INTO sessions(token_hash,username,expires_at) VALUES(?,?,?)", (hashlib.sha256(token.encode()).digest(), user["username"], now + SESSION_TTL)) + self.connection.execute("UPDATE users SET first_login_at=COALESCE(first_login_at,?),last_login_at=? WHERE username=?", (now, now, user["username"])) self.connection.commit() + current = self.connection.execute("SELECT * FROM users WHERE username=?", (user["username"],)).fetchone() return token, self._public(current) @staticmethod @@ -149,7 +158,7 @@ class AuthStore: salt = secrets.token_bytes(16) password_hash = self._hash(password, salt) with self._lock: - cursor = self.connection.execute("UPDATE users SET password_hash=?,password_salt=?,must_change_password=1 WHERE username=?", (password_hash, salt, username)) + cursor = self.connection.execute("UPDATE users SET password_hash=?,password_salt=?,must_change_password=1,password_reset_at=? WHERE username=?", (password_hash, salt, int(time.time()), username)) if not cursor.rowcount: raise AuthError("account not found") self.connection.execute("DELETE FROM sessions WHERE username=?", (username,)) @@ -157,4 +166,9 @@ class AuthStore: def list_users(self) -> list[dict]: with self._lock: - return [self._public(row) for row in self.connection.execute("SELECT * FROM users ORDER BY username COLLATE NOCASE")] + users = [] + for row in self.connection.execute("SELECT * FROM users ORDER BY username COLLATE NOCASE"): + account = self._public(row) + account.update(first_login_at=row["first_login_at"], last_login_at=row["last_login_at"], password_reset_at=row["password_reset_at"]) + users.append(account) + return users diff --git a/backend/search/evaluate_relevance.py b/backend/search/evaluate_relevance.py index 17b1ecf..aacb222 100644 --- a/backend/search/evaluate_relevance.py +++ b/backend/search/evaluate_relevance.py @@ -82,7 +82,7 @@ def main() -> int: raise SystemExit("--top-k must be greater than zero") result = evaluate(load_queries(arguments.relevance_set), arguments.url, arguments.index, arguments.top_k) print(json.dumps(result, ensure_ascii=False, indent=2)) - print(f"Akyldash · Backend v{APP_VERSION} · Frontend v0.1.0", file=sys.stderr) + print(f"Akyldash · Backend v{APP_VERSION} · Frontend v0.1.1", file=sys.stderr) return 0 diff --git a/backend/search/minjust_opensearch.py b/backend/search/minjust_opensearch.py index 3379ce9..4aabdc5 100644 --- a/backend/search/minjust_opensearch.py +++ b/backend/search/minjust_opensearch.py @@ -17,7 +17,7 @@ from typing import Iterator from search.catalog import authority_codes, legal_force_code, source_code -APP_VERSION = "0.11.0" +APP_VERSION = "0.11.1" LANGUAGES = {"ru", "ky"} DEFAULT_MAPPING = Path(__file__).with_name("minjust-fragments-index.json") @@ -460,7 +460,7 @@ def main() -> int: else: documents, fragments = export_bulk(arguments.input, arguments.output, arguments.index, arguments.limit) destination = arguments.output - print(f"documents={documents} fragments={fragments} destination={destination}\nAkyldash · Backend v{APP_VERSION} · Frontend v0.1.0") + print(f"documents={documents} fragments={fragments} destination={destination}\nAkyldash · Backend v{APP_VERSION} · Frontend v0.1.1") return 0 diff --git a/backend/search/query.py b/backend/search/query.py index 96fa150..593d6f6 100644 --- a/backend/search/query.py +++ b/backend/search/query.py @@ -208,7 +208,7 @@ def main() -> int: if arguments.top_k <= 0: raise SystemExit("--top-k must be greater than zero") print(json.dumps(search_documents(arguments.url, arguments.index, arguments.language, arguments.query, arguments.top_k), ensure_ascii=False)) - print(f"Akyldash · Backend v{APP_VERSION} · Frontend v0.1.0") + print(f"Akyldash · Backend v{APP_VERSION} · Frontend v0.1.1") return 0 diff --git a/backend/search/review.html b/backend/search/review.html index cf02cc4..2c4806b 100644 --- a/backend/search/review.html +++ b/backend/search/review.html @@ -84,6 +84,7 @@ .review__notice { padding: .75rem; background: #FFF3DA; color: #82520D; border-radius: 6px; } .review__user-list { padding: 0; list-style: none; } .review__user-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding-block: .75rem; border-block-end: 1px solid var(--line); } + .review__user-meta { display: grid; gap: .25rem; color: var(--muted); white-space: pre-line; } .review__user-reset { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; } .review__user-reset label { display: grid; gap: .25rem; margin: 0; } .review__user-reset input { width: min(15rem, 100%); } @@ -175,7 +176,7 @@
- +