Skip to content

Conversation

@issammani
Copy link
Contributor

@issammani issammani commented Oct 7, 2025

Pull Request checklist

This patch adds a new convenience method get_most_recent to retrieve the newest history metadata entries ordered by updated_at DESC with a configurable limit. Without this method, we have to use get_since(start: min_i64) and pop first n elements that we need from the vec which can be wasteful at times. Using get_most_recent should give back exactly the number of items we need ordered correctly.

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@issammani issammani changed the title Add convenience 1get_most_recent` method to fetch newest history metadata with a limit Add convenience get_most_recent method to fetch newest history metadata with a limit Oct 7, 2025
@issammani
Copy link
Contributor Author

cc @mhammond @bendk

Copy link
Member

@mhammond mhammond left a comment

Choose a reason for hiding this comment

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

This looks great! I think you will need an addition to the UDL too? And I'm wondering if we should we maybe just replace get_since() - it sounds like you are saying it's not useful so it seems likely Android might want the same thing? We wont block on Android changing, but it might be nice to leave a breadcrumb here for future us.

(It's unfortunate this "history-metadata" stuff still exists - it's basically "normal" history with some other "view time" stuff that's not synced - but it is what is it is :)


note_observation!(&conn,
url "https://example.com/1",
view_time Some(10),
Copy link
Member

Choose a reason for hiding this comment

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

we should probably have this identical for all visits to make it clear it doesn't matter. Related, this might be racey in that it probably assumes incrementing timestamps between observations, which might not be true, so the order back is different. I'm not immediately sure what to do about that :( Maybe ignore it if other tests rely on it, sqlite doing a full transaction before the timestamp advances seems unlikely to be a problem for a while?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good callout. I added both with same observation and different ones in 77cca7f. Let me know if you think we need to test more variations.

Copy link
Contributor Author

@issammani issammani Oct 8, 2025

Choose a reason for hiding this comment

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

Related, this might be racey in that it probably assumes incrementing timestamps between observations,

Yeah I can see how that can be a problem. I don't see anything in the other tests that attempts to solve it other than maybe some thread::sleep that might have been added for this ?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, maybe a comment and a super-short sleep between reecords will do for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet ! Done in f8acb29. I added a tiny helper with a comment. @mhammond if it looks good can you please merge after CI is green. I don't have merge access. Thanks !

@issammani issammani force-pushed the feat/add-convenience-method-history-meta-data branch from 60b2080 to 50eee6b Compare October 8, 2025 10:36
@issammani
Copy link
Contributor Author

I think you will need an addition to the UDL too?

True. I got so used to the macros now hahah. Added in 50eee6b

it sounds like you are saying it's not useful so it seems likely Android might want the same thing? We wont block on Android changing, but it might be nice to leave a breadcrumb here for future us.

Yeah that's the plan. I will also change Android after this lands and we can remove it after. For some reason, I always end up breaking android when I do breaking changes 🙈 So this seems safer. Added ticket and comment on top of method to track this in d7eaab9 😄

@issammani issammani requested a review from mhammond October 8, 2025 10:47

### Swift
- Added `@unchecked Sendable` to classes that conform to `FeatureManifestInterface`. ([#6963](https://github.com/mozilla/application-services/pull/6963)
- Added `@unchecked Sendable` to classes that conform to `FeatureManifestInterface`. ([#6963](https://github.com/mozilla/application-services/pull/6963))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was missing a ) at the end and it bothered me 😂

mhammond
mhammond previously approved these changes Oct 8, 2025
Copy link
Member

@mhammond mhammond left a comment

Choose a reason for hiding this comment

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

this is great, thanks!


note_observation!(&conn,
url "https://example.com/1",
view_time Some(10),
Copy link
Member

Choose a reason for hiding this comment

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

yeah, maybe a comment and a super-short sleep between reecords will do for now

@mergify mergify bot dismissed mhammond’s stale review October 8, 2025 13:42

The pull request has been modified, dismissing previous reviews.

@issammani issammani requested a review from mhammond October 8, 2025 13:44
@mhammond mhammond added this pull request to the merge queue Oct 8, 2025
Merged via the queue into mozilla:main with commit ef10803 Oct 8, 2025
13 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.

2 participants