Enhancing GitHub Sync Handling: A Dive into Recent Improvements

Introduction

In our ongoing effort to enhance the GitHub sync functionality in the devlog-ist project, we identified issues relating to the accuracy and efficiency of code review scheduling. The recent update aimed to address these challenges by refining the code review sync process and improving the user experience.

The Problem

Previously, our system suffered from two major limitations:

  • Data Persistence: Some code reviews were not being saved correctly due to a missing crucial database call.
  • Sync Granularity: The sync frequency was set to a 29-day window, making the process sluggish and less responsive to changes in the repository.

These issues led to outdated data being displayed to users, diminishing the overall reliability of our application.

The Solution

We implemented several changes to remedy these issues, primarily focusing on the synchronization logic and enhancing the date picker functionality. Below are the key updates made in this commit:

Code Review Persistence

To ensure all code reviews are correctly saved, we added a missing call to CodeReview::create() in the sync job. This adjustment guarantees that code reviews are reliably persisted in our database, which was a critical oversight.

Improved Sync Job Frequency

We modified the sync job granularity from a 29-day window to a more responsive 1-day window. This allows for a more frequent and accurate update of the GitHub code review status, enhancing real-time synchronization for our users. Here is the relevant code snippet that captures this change:

// Previously there was a 29-day sync limit
public function syncGitHubActivity() {
    $lastSyncDate = now()->subDays(1); // Modernizing to 1-day sync
    $this->syncReviews($lastSyncDate);
}

Flexible Date Range

Another substantial enhancement was allowing an unlimited date range during the initial sync. This means that new users can push all their historical data without limitation, improving the onboarding experience. After the first sync, the range is capped at 90 days due to GitHub API limitations.

Dynamic Date Picker Defaults

We also overhauled the default values of our date picker to default to the day after the last synced commit date. This change provides users with a more intuitive experience, allowing them to quickly select an appropriate date for syncing. Here's how we implemented this:

$datePickerDefault = function () {
    $lastCommitDate = Commit::query()->where('user_id', auth()->id())->max('github_created_at');
    return $lastCommitDate ? Carbon::parse($lastCommitDate)->addDay() : Carbon::now()->subDay();
};

API Limit Improvements

We also removed the verbose limitations displayed in the date picker for the 90-day API limit and added translations for relevant error messages in multiple languages. This makes our application more accessible to a diverse user base.

Conclusion

The recent updates to our GitHub sync feature significantly enhance user experience by streamlining the review synchronization process and providing more intuitive interactions. Key takeaways from this development include:

  • Ensuring data persistence is crucial for functionality.
  • More frequent sync intervals lead to improved application reliability.
  • Enhancements in UI components (like date pickers) can greatly improve user efficiency.

These updates not only address existing pain points but also set a foundation for further development and scaling of our sync capabilities.


Generated with Devlog.ist

Gerardo Ruiz

Gerardo Ruiz

Author

Share: