Skip to content

Updated action.js to Handle Locked LeetCode Premium Problems and Improve Sync Reliability #62

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

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

AlyHG
Copy link
Contributor

@AlyHG AlyHG commented Jun 19, 2024

Description:
This pull request addresses an issue where users with previously unlocked LeetCode premium problems would experience failures during the sync process. The following changes have been made:

  • Error Handling for Locked Problems: Added error handling in the getInfo function to skip locked problems. When the function encounters a locked problem (HTTP 403 error), it logs a message and skips the problem instead of retrying or throwing an exception.
  • Fetching Question Data: Updated the getQuestionData function to handle errors when fetching question data for locked problems. If fetching the question data results in a locked problem error (HTTP 403), it logs the error and returns null to indicate that the problem should be skipped.
  • Sync Function Modification: Modified the sync function to continue syncing other problems even if some are locked, ensuring that locked problems do not cause the entire sync process to fail.
  • Additional Logging: Added logging to help identify and skip locked problems during the sync process.

These changes improve the sync process by handling scenarios where some LeetCode problems are locked, allowing the action to continue syncing all available, unlocked problems successfully.

AlyHG added 3 commits June 19, 2024 11:04
Added error handling in the `getInfo` function to skip locked problems. When the function encounters a locked problem (HTTP 403 error), it logs a message and skips the problem instead of retrying or throwing an exception.
  
- Updated the `getQuestionData` function to handle locked problems.  If fetching the question data results in a locked problem error (HTTP 403), it logs the error and returns null to indicate that the problem should be skipped.
  
Modified the `sync` function to skip submissions related to locked problems. It continues the sync process for other problems, ensuring that locked problems do not cause the entire sync process to fail.
Copy link
Owner

@joshcai joshcai left a comment

Choose a reason for hiding this comment

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

Thanks for the improvement, really appreciate it!

src/action.js Outdated
@@ -415,13 +425,22 @@ async function sync(inputs) {
leetcodeSession,
leetcodeCSRFToken,
);
if (!submission) {
Copy link
Owner

Choose a reason for hiding this comment

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

Could you also do "submission === null" here to be consistent with L440?

README.md Outdated
@@ -48,7 +48,7 @@ GitHub Action for automatically syncing LeetCode submissions to a GitHub reposit

steps:
- name: Sync
uses: joshcai/leetcode-sync@v1.6
uses: AlyHG/leetcode-sync@master
Copy link
Owner

Choose a reason for hiding this comment

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

Could you revert this line? I'll create a new release after this is in, and bump the version number up.

README.md Outdated
@@ -111,3 +111,17 @@ Special thanks to the following people who helped beta test this GitHub Action a
- [uakfdotb](https://github.com/uakfdotb)
- [hexecute](https://github.com/hexecute)
- [JonathanZhu11](https://github.com/JonathanZhu11)

## Updated by [Aly Ghallab](https://github.com/AlyHG) to Handle Locked LeetCode Premium Problems and Improve Sync Reliability - June 19, 2024
Copy link
Owner

Choose a reason for hiding this comment

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

Would it be okay if I add this info in the release notes section when creating a new release? e.g. similar to https://github.com/joshcai/leetcode-sync/releases/tag/v1.6

AlyHG added 2 commits June 24, 2024 10:39
…for merge

- Changed condition to "submission === null" in src/action.js for syntax consistency.
- Reverted "uses" line in README.md to point back to joshcai/[email protected].
- Removed self-crediting section from README.md. Agreed to include this information in the release notes instead.
@AlyHG
Copy link
Contributor Author

AlyHG commented Jun 24, 2024

Hey, I applied your feedback and made the changes requested. Let me know if there's anything else.

@joshcai
Copy link
Owner

joshcai commented Jun 26, 2024

Thanks! Looks good to me now - merging.

@joshcai joshcai merged commit b20aa38 into joshcai:master Jun 26, 2024
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.

No Longer Have LC Premium - Issue Committing Locked Problems
2 participants