Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End of Year: improve listening history sync #523

Merged
merged 7 commits into from
Nov 16, 2022

Conversation

leandroalonso
Copy link
Member

📘 Project: #376

This PR improves and speeds up the process of syncing the 2022 listening history. I tested with an account that was taking ~6 minutes to sync. This has been reduced to ~34s. There's still room for improvement but I'll leave that for another PR.

Before the change: sync took 296.6710090637207
After the change: sync took 34.58926796913147

Improvements

The way we were doing before, we would check the database once per episode, it doesn't matter if the user had them or not. For users with a big list of episodes, the performance was very poor.

Instead, what we do now is to check the episodes that are missing and request and add only them.

To test

  1. Run the TestFlight version
  2. Check your stories
  3. Run this branch
  4. ✅ Check your stories and make sure both versions match

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

@leandroalonso leandroalonso added the [Project] End of Year 2023 End of Year project label Nov 16, 2022
@leandroalonso leandroalonso added this to the 7.27 ❄️ milestone Nov 16, 2022
@leandroalonso leandroalonso requested a review from a team as a code owner November 16, 2022 20:26
@@ -205,7 +205,7 @@ class EndOfYearDataManager {
WHERE `\(DataManager.podcastTableName)`.uuid = `\(DataManager.episodeTableName)`.podcastUuid and
\(listenedEpisodesThisYear)
GROUP BY podcastUuid
ORDER BY played_episodes DESC
ORDER BY totalPlayedTime DESC
Copy link
Member Author

@leandroalonso leandroalonso Nov 16, 2022

Choose a reason for hiding this comment

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

I changed that because if a person listened to, let's say, 40 episodes of a podcast that has 1-minute episodes, that would be their top podcast. Which is weird (and we already received feedback about that).

Copy link
Contributor

@emilylaguna emilylaguna left a comment

Choose a reason for hiding this comment

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

Left a few comments.

@@ -933,4 +933,8 @@ public extension DataManager {
func longestEpisode() -> Episode? {
endOfYearManager.longestEpisode(dbQueue: dbQueue)
}

func episodesThatExists(uuids: [String]) -> [String] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func episodesThatExists(uuids: [String]) -> [String] {
func episodesThatExist(uuids: [String]) -> [String] {

@@ -256,6 +256,32 @@ class EndOfYearDataManager {
return episode
}

/// Given a list of UUIDs, return which UUIDs are present on the database
func episodesThatExists(dbQueue: FMDatabaseQueue, uuids: [String]) -> [String] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func episodesThatExists(dbQueue: FMDatabaseQueue, uuids: [String]) -> [String] {
func episodesThatExist(dbQueue: FMDatabaseQueue, uuids: [String]) -> [String] {

@leandroalonso leandroalonso merged commit 9e97385 into release/7.27 Nov 16, 2022
@leandroalonso leandroalonso deleted the task/376-improve-sync-listening-history branch November 16, 2022 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Project] End of Year 2023 End of Year project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants