You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于后续记录值调整活动时间戳的规则实现技术问询

Timestamp Update Logic for Activity Records

Hey there, let's break down how to handle updating timestamps based on subsequent activity records, following your specific rules. Here's a clear, actionable approach:

Core Update Rules

  • First, group all activity records by workID—we only care about comparing activities within the same work group.
  • Sort each workID group by start time (this ensures we're checking the correct "previous" and "next" activities in chronological order).
  • Iterate through each activity in the sorted group (skip the last one, since there's no subsequent activity):
    • Compare the current activity's end time with the next activity's start time:
      • If the next activity starts before the current one ends (next.start < current.end):
        • Update the current activity's start time to next.start - 1 second
        • Update the current activity's end time to next.start - 1 second
      • If there's no overlap, leave the current activity's timestamps as-is.

Key Notes to Remember

  • Duplicate workAc entries within the same workID are totally fine—no need to remove them. Just process each record in order.
  • Don't worry about activities where start time equals end time, or where they differ. That's intentional per your requirements, so we ignore those cases and focus only on the overlap rule.
  • Always make sure you're only comparing activities that share the same workID—different works don't interfere with each other.

Quick Example to Illustrate

Let's say we have two activities under the same workID:

  1. Activity A: start=2024-05-20 10:00:00, end=2024-05-20 10:30:00
  2. Activity B: start=2024-05-20 10:20:00, end=2024-05-20 10:40:00

Since Activity B starts before Activity A ends, we adjust Activity A's timestamps:

  • Updated Activity A: start=2024-05-20 10:19:59, end=2024-05-20 10:19:59

Now there's no overlap between the two activities, which fits your requirement perfectly.

内容的提问来源于stack exchange,提问作者kzmlbyrk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:14:51