MCPcopy
hub / github.com/HisMax/RedInk / update_record

Method update_record

backend/services/history.py:207–292  ·  view source on GitHub ↗

更新历史记录 支持部分更新,只更新提供的字段。 每次更新都会自动刷新 updated_at 时间戳。 Args: record_id: 记录 ID outline: 大纲内容(可选,用于修改大纲) images: 图片信息(可选,包含 task_id 和 generated 列表) status: 状态(可选) thumbnail: 缩略图文件名(可选) Returns:

(
        self,
        record_id: str,
        outline: Optional[Dict] = None,
        images: Optional[Dict] = None,
        status: Optional[str] = None,
        thumbnail: Optional[str] = None
    )

Source from the content-addressed store, hash-verified

205 return os.path.exists(record_path)
206
207 def update_record(
208 self,
209 record_id: str,
210 outline: Optional[Dict] = None,
211 images: Optional[Dict] = None,
212 status: Optional[str] = None,
213 thumbnail: Optional[str] = None
214 ) -> bool:
215 """
216 更新历史记录
217
218 支持部分更新,只更新提供的字段。
219 每次更新都会自动刷新 updated_at 时间戳。
220
221 Args:
222 record_id: 记录 ID
223 outline: 大纲内容(可选,用于修改大纲)
224 images: 图片信息(可选,包含 task_id 和 generated 列表)
225 status: 状态(可选)
226 thumbnail: 缩略图文件名(可选)
227
228 Returns:
229 bool: 更新是否成功,记录不存在时返回 False
230
231 状态流转说明:
232 draft -> generating: 开始生成图片
233 generating -> partial: 部分图片生成完成
234 generating -> completed: 所有图片生成完成
235 generating -> error: 生成过程出错
236 partial -> generating: 继续生成剩余图片
237 partial -> completed: 剩余图片生成完成
238 """
239 # 获取现有记录
240 record = self.get_record(record_id)
241 if not record:
242 return False
243
244 # 更新时间戳
245 now = datetime.now().isoformat()
246 record["updated_at"] = now
247
248 # 更新大纲内容(支持修改大纲)
249 if outline is not None:
250 record["outline"] = outline
251
252 # 更新图片信息
253 if images is not None:
254 record["images"] = self._merge_safe_images(record.get("images"), images)
255
256 # 更新状态(状态流转)
257 if status is not None:
258 record["status"] = self._protect_status(record.get("status"), status, record)
259
260 # 更新缩略图
261 if thumbnail is not None:
262 record["thumbnail"] = thumbnail
263
264 # 保存完整记录

Calls 7

get_recordMethod · 0.95
_merge_safe_imagesMethod · 0.95
_protect_statusMethod · 0.95
_get_record_pathMethod · 0.95
_load_indexMethod · 0.95
_save_indexMethod · 0.95
getMethod · 0.80