-
Notifications
You must be signed in to change notification settings - Fork 1
Feat(Reports): Add like feature #2
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
base: master
Are you sure you want to change the base?
Conversation
需要为 users 表增加 feed_token 字段(nullable text/varchar)。
(无语住了 现在只要是没有被禁的用户都可以用自己的token订阅
日志含 subscriber id/name、author id/name、时间戳(不记录 token),用现有的 tracing 记录器输出。
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
Co-authored-by: Reverier Xu <[email protected]>
This reverts commit 1f0d224.
|
需要在reports数据表中添加likes列(text),将以数组的形式存储点赞的用户 |
Reverier-Xu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
挠头,我觉得ai vibe coding还是太早了,要不再学一学?
sea-orm ref https://www.sea-ql.org/SeaORM/docs/generate-entity/column-types/
| pub week: i32, | ||
| #[sea_orm(column_type = "Text", nullable)] | ||
| pub content: Option<String>, | ||
| #[sea_orm(column_type = "Text", nullable)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要这么存likes,rust sea-orm有json相关的序列化功能,包括后面手搓的序列化代码也是不必要的
| // Perform an atomic update of the likes column and then fetch the | ||
| // updated row to return a Model. This reduces the chance of clobbering | ||
| // other fields and makes the operation observable to callers. | ||
| let _res = Entity::update_many() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只是一个model更新用得着update many吗,update many本身性能很差的
Reverier-Xu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 不要自己写json序列化与反序列化,使用seaorm types
- 使用正确的数据库操作函数
likes列的数据类型改为json,默认值为[]。 |
|
已有数据不好加默认值的,得全表更新,改成nullable好一点
…________________________________
发件人: 肖宗林 ***@***.***>
发送时间: Thursday, November 13, 2025 3:47:08 PM
收件人: XDSEC/weekly_report ***@***.***>
抄送: Reverier Xu ***@***.***>; Mention ***@***.***>
主题: Re: [XDSEC/weekly_report] Feat(Reports): Add like feature (PR #2)
[https://avatars.githubusercontent.com/u/205417095?s=20&v=4]Xiaozonglin left a comment (XDSEC/weekly_report#2)<#2 (comment)>
需要在reports数据表中添加likes列(text),将以数组的形式存储点赞的用户
likes列的数据类型改为json,默认值为[]。
―
Reply to this email directly, view it on GitHub<#2 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJ76TNKL3BX2FT54V5RAN4D34QZPZAVCNFSM6AAAAACLJR2Z7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMRWGEZTKNBVGA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
| use sea_orm::{ | ||
| entity::prelude::*, ActiveValue, FromQueryResult, IntoActiveModel, JoinType, QuerySelect, | ||
| }; | ||
| use sea_orm::JsonValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是这么用的啊,参考 https://www.sea-ql.org/SeaORM/docs/generate-entity/column-types 直接使用结构体定义一个数组结构
| pub content: Option<String>, | ||
| // Use SeaORM's JsonValue for JSON column storage | ||
| #[sea_orm(column_type = "Json", nullable)] | ||
| pub likes: Option<JsonValue>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的效果应该是
pub likes: Likes
...
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, FromJsonQueryResult, ...)]
struct Likes(Vec<i64>)
我之前没弄分支,所以...之前的commit都跟过来了


