Skip to content

Conversation

@mustafa3rsan
Copy link
Contributor

@mustafa3rsan mustafa3rsan commented Jan 17, 2026

Note

Fixes time range handling for LinkedIn lead form responses.

  • In lead_form_responses, when submittedAt.end_value is missing, toDate now defaults to int(pendulum.now(tz="UTC").int_timestamp * 1000) to match the API’s millisecond expectation
  • Aligns fallback end time with existing millisecond-based submittedAt values to prevent mismatched timestamp units

Written by Cursor Bugbot for commit 0fe97c0. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected end-date handling for lead form responses: when an end date isn't provided, the end boundary is now set as a millisecond-precision integer timestamp, while explicitly supplied end dates are preserved.

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

@mustafa3rsan mustafa3rsan changed the title fix enddate fix enddate for linkedin Jan 17, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Modified lead_form_responses to use an integer millisecond epoch timestamp for endDate when end_value is absent, replacing a UTC datetime object in the submittedAtTimeRange construction.

Changes

Cohort / File(s) Summary
Lead Form Response Date Handling
ingestr/src/linkedin_ads/__init__.py
When end_value is missing, endDate is now int(pendulum.now(tz="UTC").int_timestamp * 1000) (integer milliseconds since epoch) instead of a UTC datetime object, altering the submittedAtTimeRange query parameter format.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibble code in morning light,

milliseconds now take flight,
One small hop from time to time,
Precise and tidy, neat and prime,
Hooray — the timestamps feel just right!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix enddate for linkedin' directly relates to the main change: updating the endDate/endDate computation for LinkedIn Ads API to use millisecond-precision timestamps.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. ingestr/src/linkedin_ads/__init__.py, line 184 (link)

    syntax: Missing int() wrapper causes float timestamp

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

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: 1

🤖 Fix all issues with AI agents
In `@ingestr/src/linkedin_ads/__init__.py`:
- Around line 190-193: The ternary for computing toDate uses truthiness on
submittedAt.end_value which wrongly treats 0 as missing; change the check to
explicit None comparison (use "submittedAt.end_value is not None") so toDate
uses the provided 0/epoch value when present and only falls back to
pendulum.now() when end_value is None; update the expression around toDate and
the referenced symbol submittedAt.end_value accordingly.

Comment on lines 190 to +193
toDate = (
submittedAt.end_value if submittedAt.end_value else pendulum.now(tz="UTC")
submittedAt.end_value
if submittedAt.end_value
else int(pendulum.now(tz="UTC").int_timestamp * 1000)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Guard end_value with is not None instead of truthiness.

submittedAt.end_value could be 0 (epoch) in tests or edge cases, which would incorrectly fall back to now. Use an explicit None check.

Suggested fix
-        toDate = (
-            submittedAt.end_value
-            if submittedAt.end_value
-            else int(pendulum.now(tz="UTC").int_timestamp * 1000)
-        )
+        toDate = (
+            submittedAt.end_value
+            if submittedAt.end_value is not None
+            else int(pendulum.now(tz="UTC").int_timestamp * 1000)
+        )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
toDate = (
submittedAt.end_value if submittedAt.end_value else pendulum.now(tz="UTC")
submittedAt.end_value
if submittedAt.end_value
else int(pendulum.now(tz="UTC").int_timestamp * 1000)
toDate = (
submittedAt.end_value
if submittedAt.end_value is not None
else int(pendulum.now(tz="UTC").int_timestamp * 1000)
)
🤖 Prompt for AI Agents
In `@ingestr/src/linkedin_ads/__init__.py` around lines 190 - 193, The ternary for
computing toDate uses truthiness on submittedAt.end_value which wrongly treats 0
as missing; change the check to explicit None comparison (use
"submittedAt.end_value is not None") so toDate uses the provided 0/epoch value
when present and only falls back to pendulum.now() when end_value is None;
update the expression around toDate and the referenced symbol
submittedAt.end_value accordingly.

@mustafa3rsan mustafa3rsan merged commit 9a73123 into main Jan 17, 2026
21 of 27 checks passed
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.

3 participants