Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ refactor: refactor the drizzle code style #5058

Merged
merged 4 commits into from
Dec 17, 2024
Merged

Conversation

canisminor1990
Copy link
Member

@canisminor1990 canisminor1990 commented Dec 17, 2024

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

  • 优化 drizzle-orm/expressions 引用
  • 去除 execute()
  • 统一为箭头函数

📝 补充信息 | Additional Information

Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lobe-chat-database ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 4:09pm
lobe-chat-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 4:09pm

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 17, 2024
@lobehubbot
Copy link
Member

👍 @canisminor1990

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 99.01478% with 2 lines in your changes missing coverage. Please review.

Project coverage is 91.95%. Comparing base (ca40f54) to head (93c1b15).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/database/server/models/message.ts 96.29% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5058      +/-   ##
==========================================
- Coverage   91.95%   91.95%   -0.01%     
==========================================
  Files         548      548              
  Lines       41423    41398      -25     
  Branches     2511     2354     -157     
==========================================
- Hits        38091    38067      -24     
+ Misses       3332     3331       -1     
Flag Coverage Δ
app 91.95% <99.01%> (-0.01%) ⬇️
server 98.14% <99.01%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 依赖导入,优先用 drizzle-orm/expressions 而不是 drizzle-orm

原因是 import { xxx } from 'drizzle-orm' 的index是个桶文件,会大大提高编译的耗时(详见 https://vercel.com/blog/how-we-optimized-package-imports-in-next-js );

  1. 优先使用 toggleKnowledgeBase = async (agentId: string, knowledgeBaseId: string, enabled?: boolean) => 而不是 async toggleKnowledgeBase(agentId: string, knowledgeBaseId: string, enabled?: boolean) {

因为 xxx() 这种写法没有确保闭包,用到 this. 的时候在特定场景下会抛错,很容易踩坑。

比如 useSWR('xxx', userService.abc ) ,如果 abc 是一个 function 而不是箭头函数,那么 service 里面的 this 就会挂掉。

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 17, 2024
@arvinxx arvinxx changed the title ♻️ refactor: Update drizzle code style ♻️ refactor: refactor the drizzle code style Dec 17, 2024
@arvinxx arvinxx merged commit 4057ad3 into main Dec 17, 2024
11 checks passed
@arvinxx arvinxx deleted the refactor/drizzle-style branch December 17, 2024 16:19
@lobehubbot
Copy link
Member

❤️ Great PR @canisminor1990 ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx@canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。

github-actions bot pushed a commit that referenced this pull request Dec 17, 2024
### [Version&nbsp;1.36.32](v1.36.31...v1.36.32)
<sup>Released on **2024-12-17**</sup>

#### ♻ Code Refactoring

- **misc**: Refactor the drizzle code style.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Refactor the drizzle code style, closes [#5058](#5058) ([4057ad3](4057ad3))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehub lobehub deleted a comment from Richardallis411 Dec 17, 2024
@lobehubbot
Copy link
Member

🎉 This PR is included in version 1.36.32 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Dec 19, 2024
### [Version&nbsp;1.78.13](v1.78.12...v1.78.13)
<sup>Released on **2024-12-19**</sup>

#### ♻ Code Refactoring

- **misc**: Refactor the drizzle code style.

#### 🐛 Bug Fixes

- **misc**: Fix GitHub model fetch, fix pdf preview with capital ext.

#### 💄 Styles

- **misc**: Improve home page loading for better UX.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Refactor the drizzle code style, closes [lobehub#5058](https://github.com/bentwnghk/lobe-chat/issues/5058) ([4057ad3](4057ad3))

#### What's fixed

* **misc**: Fix GitHub model fetch, closes [lobehub#4645](https://github.com/bentwnghk/lobe-chat/issues/4645) ([b69dce3](b69dce3))
* **misc**: Fix pdf preview with capital ext, closes [lobehub#5074](https://github.com/bentwnghk/lobe-chat/issues/5074) ([3f9470f](3f9470f))

#### Styles

* **misc**: Improve home page loading for better UX, closes [lobehub#5075](https://github.com/bentwnghk/lobe-chat/issues/5075) ([99026bb](99026bb))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants