You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.2 KiB
53 lines
2.2 KiB
package memory
|
|
|
|
import (
|
|
"yunyan/comm"
|
|
"yunyan/lego/sys/mysql"
|
|
)
|
|
|
|
/*
|
|
存量修正:把被 gorm 的 `default:` 标签吞掉的会议待办标记改回来。
|
|
|
|
起因见 model.go 的 addItem —— 2026-09-18 之前 ExtractMeetingTodos 写的
|
|
DateCertain:false / RemindAhead:0 一条都没落进库,测试库里 16 条会议待办
|
|
全是 date_certain=1 / remind_ahead=5。代码修好之后**新数据**才对,
|
|
已经写歪的这些得单独扶正,否则用户的日历里那批待办照旧在 08:55 响提醒。
|
|
|
|
三条刻意的边界:
|
|
|
|
- **只碰 source='meeting' 且 user_edited=0 的行**。用户改过的项已经是他自己的东西,
|
|
哪怕当初的值来自 bug,也不该在他背后再改一次。
|
|
- **助手闹钟那批 remind_ahead=5 不动**。当初用户到底有没有选「不提醒」现在已无从知道,
|
|
而 5 分钟正是产品默认值,改了反而可能把用户设过的提醒抹掉。
|
|
- **date_certain 只回退「有 due_raw 却仍落在会议当天」的那些**。当初真从原文推算出
|
|
截止日的项本来就该是 1,无法与被吞掉的那批区分,所以只挑这个能确定判错的子集。
|
|
|
|
幂等:条件里带了「当前值不等于目标值」,跑第二遍影响 0 行。
|
|
不写 next_remind_at:全项目没有任何地方读它(只有 recalcRemind 在写),
|
|
动它只会扩大这次修正的影响面。
|
|
*/
|
|
|
|
// fixSwallowedDefaults 修正存量会议待办被默认值覆盖的两列,返回改动行数。
|
|
func (this *modelComp) fixSwallowedDefaults() (int64, error) {
|
|
var total int64
|
|
|
|
// 会议待办一律不提醒
|
|
tx := mysql.Table(comm.TableMemoryItem).
|
|
Where("source = ? AND user_edited = ? AND remind_ahead <> ?", comm.MemorySrcMeeting, false, 0).
|
|
Update("remind_ahead", 0)
|
|
if tx.Error != nil {
|
|
return total, tx.Error
|
|
}
|
|
total += tx.RowsAffected
|
|
|
|
// 有截止原文、却没推算出具体日期(= 仍落在会议当天)→ 该进「待定日期」分组
|
|
tx = mysql.Table(comm.TableMemoryItem).
|
|
Where("source = ? AND user_edited = ? AND due_raw <> ? AND date_certain = ?",
|
|
comm.MemorySrcMeeting, false, "", true).
|
|
Update("date_certain", false)
|
|
if tx.Error != nil {
|
|
return total, tx.Error
|
|
}
|
|
total += tx.RowsAffected
|
|
return total, nil
|
|
}
|
|
|