Skip to content

fix: [#690] resolve issue with second-level cron jobs on OnOneServer#1053

Merged
almas-x merged 1 commit intov1.15.xfrom
almas/fix
May 29, 2025
Merged

fix: [#690] resolve issue with second-level cron jobs on OnOneServer#1053
almas-x merged 1 commit intov1.15.xfrom
almas/fix

Conversation

@almas-x
Copy link
Contributor

@almas-x almas-x commented May 28, 2025

📑 Description

Closes goravel/goravel#690

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings May 28, 2025 08:50
@almas-x almas-x requested a review from a team as a code owner May 28, 2025 08:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue with second-level cron jobs on OnOneServer by adjusting how the key suffix is computed.

  • Updates key suffix computation by checking the cron string format
  • Introduces conditional logic to use a more granular time format when necessary

Comment on lines 88 to +91
if event.IsOnOneServer() && event.GetName() != "" {
if app.cache.Lock(event.GetName()+carbon.Now().Format("Hi"), 1*time.Hour).Get() {
keySuffix := carbon.Now().Format("Hi")
if segments := strings.Split(event.GetCron(), " "); len(segments) == 6 {
keySuffix = carbon.Now().Format("His")
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

Consider caching the result of carbon.Now() in a local variable so that both calls (for "Hi" and "His") use the same timestamp, preventing potential inconsistencies if the time changes between calls.

Copilot uses AI. Check for mistakes.
if event.IsOnOneServer() && event.GetName() != "" {
if app.cache.Lock(event.GetName()+carbon.Now().Format("Hi"), 1*time.Hour).Get() {
keySuffix := carbon.Now().Format("Hi")
if segments := strings.Split(event.GetCron(), " "); len(segments) == 6 {
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

[nitpick] It might be beneficial to trim the cron string before splitting to handle any extraneous whitespace that could lead to an unexpected segment count.

Suggested change
if segments := strings.Split(event.GetCron(), " "); len(segments) == 6 {
if segments := strings.Split(strings.TrimSpace(event.GetCron()), " "); len(segments) == 6 {

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented May 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (v1.15.x@4a70668). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             v1.15.x    #1053   +/-   ##
==========================================
  Coverage           ?   68.78%           
==========================================
  Files              ?      218           
  Lines              ?    18869           
  Branches           ?        0           
==========================================
  Hits               ?    12979           
  Misses             ?     5229           
  Partials           ?      661           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Nice 👍

@almas-x almas-x merged commit dc39568 into v1.15.x May 29, 2025
13 of 15 checks passed
@almas-x almas-x deleted the almas/fix branch May 29, 2025 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants