refactor: update process_pending_tasks to accept database type and ad… - #1
Open
Rjiegit wants to merge 1 commit into
Open
refactor: update process_pending_tasks to accept database type and ad…#1Rjiegit wants to merge 1 commit into
Rjiegit wants to merge 1 commit into
Conversation
…just streamlit_app to use selected database
There was a problem hiding this comment.
Pull Request Overview
该 PR 重构了 process_pending_tasks 函数,使其能够接受数据库类型参数,并调整了 streamlit 应用使用选定的数据库。
- 更新
process_pending_tasks函数以接受可选的数据库类型参数 - 修改 streamlit 应用以传递用户选择的数据库类型到处理函数
- 简化 UI,移除重复的数据库选择器,统一使用顶部选择器
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| processing.py | 重构 process_pending_tasks 函数以接受可选的数据库类型参数 |
| streamlit_app.py | 修改应用以使用统一的数据库选择器并传递选择到处理函数 |
| If db_type is provided, it will be used to select the database; otherwise, | ||
| the environment variable DB_TYPE (default sqlite) is used. | ||
| """ | ||
| db = DBFactory.get_db(db_type) if db_type else get_db_client() |
There was a problem hiding this comment.
建议导入 DBFactory。从上下文看,这里直接使用了 DBFactory.get_db(),但在文件顶部应该确保正确导入了 DBFactory 模块。
| # This block will execute when the state is True after a rerun | ||
| if st.session_state.processing_tasks: | ||
| # Use the top selector's current choice from session state | ||
| selected_db = st.session_state.get("add_db", "SQLite") |
There was a problem hiding this comment.
硬编码的默认值 'SQLite' 在多处使用。建议将其定义为常量,例如 DEFAULT_DB_TYPE = 'SQLite',以提高代码的可维护性。
| "Select Database to View", ["SQLite", "Notion"], key="view_db" | ||
| ) | ||
| # Use the top selectbox choice for viewing as well to avoid duplicate selectors | ||
| db_choice_view = st.session_state.get("add_db", "SQLite") |
There was a problem hiding this comment.
与上面的评论相同,这里也使用了硬编码的 'SQLite' 默认值。应该使用统一的常量。
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.
…just streamlit_app to use selected database