Skip to content

Conversation

@rexa0310
Copy link
Contributor

@rexa0310 rexa0310 commented Jan 16, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed inconsistent timestamp formatting in scheduled tasks by ensuring ISO-8601 string format is used consistently throughout the analytic pipeline.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

The _add_one_time_schedule function now converts numeric epoch schedules to ISO-8601 strings once and reuses that serialized value downstream, eliminating redundant serialization calls. This maintains consistent internal representation throughout the scheduling workflow.

Changes

Cohort / File(s) Summary
Schedule Serialization Optimization
kairon/events/definitions/analytic_pipeline_handler.py
Refactored epoch-to-ISO-8601 conversion to occur once and reuse the serialized string value for both scheduler_config updates and event server notifications, eliminating redundant isoformat() calls

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A bunny hops through timestamps bright,
Converting once, not thrice in sight!
From epoch dust to ISO gold,
One string to rule them all, so bold! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: converting epoch time to ISO format for database storage in the scheduler configuration.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89e6597 and e325cec.

📒 Files selected for processing (1)
  • kairon/events/definitions/analytic_pipeline_handler.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Python CI
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
kairon/events/definitions/analytic_pipeline_handler.py (2)

124-129: Conversion logic looks correct.

The epoch-to-ISO conversion correctly applies timezone before serialization, and storing the normalized string in config ensures consistent DB representation.

Minor note: if run_at is neither int/float nor already a string (e.g., a datetime passed directly), it will be stored and forwarded as-is. If the downstream API always expects a string, consider adding validation or a fallback conversion for other types.


134-140: LGTM!

Since run_at is already converted to an ISO string at line 127, passing it directly here avoids redundant serialization.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
kairon/events/definitions/analytic_pipeline_handler.py (1)

200-215: Inconsistent format between add and update operations.

The _update_schedule method still saves a datetime object to scheduler_config["schedule"] (line 206), while _add_one_time_schedule now saves an ISO string (line 129). This creates inconsistent data types in the database for the same field.

To align with the PR objective of saving epoch time in ISO format, apply the same conversion here:

Proposed fix
             elif expression_type == "epoch":

                 epoch_time = int(schedule)
                 tzinfo = ZoneInfo(timezone) if timezone else ZoneInfo("UTC")
                 run_at = datetime.fromtimestamp(epoch_time, tzinfo)
+                run_at = run_at.isoformat()

-                scheduler_config["schedule"] = run_at
+                scheduler_config["schedule"] = run_at

                 Utility.request_event_server(
                     EventClass.analytics_pipeline,
                     payload,
                     method="PUT",
                     is_scheduled=True,
-                    run_at=run_at.isoformat(),
+                    run_at=run_at,
                     timezone=timezone
                 )
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89e6597 and e325cec.

📒 Files selected for processing (1)
  • kairon/events/definitions/analytic_pipeline_handler.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Python CI
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
kairon/events/definitions/analytic_pipeline_handler.py (2)

124-129: Conversion logic looks correct.

The epoch-to-ISO conversion correctly applies timezone before serialization, and storing the normalized string in config ensures consistent DB representation.

Minor note: if run_at is neither int/float nor already a string (e.g., a datetime passed directly), it will be stored and forwarded as-is. If the downstream API always expects a string, consider adding validation or a fallback conversion for other types.


134-140: LGTM!

Since run_at is already converted to an ISO string at line 127, passing it directly here avoids redundant serialization.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant