-
Notifications
You must be signed in to change notification settings - Fork 2
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
Auto-generated Pull Request for fix/empty-publication #429
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…function The cache fetching logic was extracted from the FetchPublicationFromEuroPMC function into a new function called FetchPublicationFromCache. This change was made to improve code readability and maintainability. Now, the FetchPublicationFromEuroPMC function is more focused on its main responsibility, which is fetching publications from EuroPMC. The cache fetching logic is now encapsulated in its own function, making the code easier to understand and modify if needed.
…on by removing unnecessary error handling The FetchPublicationFromEuroPMC function was simplified by removing the error handling related to the EuroPMC2Pub function. This change was made because the EuroPMC2Pub function itself is responsible for handling its own errors.
… when no publication is found The EuroPMC2Pub function has been refactored to return an error instead of an empty Publication object when no publication is found. This change makes error handling more explicit and prevents potential issues downstream where an empty Publication object might be incorrectly processed. The function now also takes an additional 'id' parameter, which is used to provide a more specific error message when no publication is found.
…caching of publications The unused repo parameter was removed from the FetchPublicationFromEuroPMC function to clean up the code and improve readability. A new function, StorePublicationInCache, was added to handle the caching of publications. This separates the concerns of fetching and caching publications, making the code more maintainable and easier to understand.
…function The redis key creation was being repeated in multiple places in the code. To adhere to the DRY (Don't Repeat Yourself) principle, the key creation logic has been extracted into a separate function named 'makeRedisKey'.
The changes introduce a caching mechanism for publication data. Now, before fetching data from EuroPMC, the system checks if the data is already available in the cache. If it is, the cached data is returned, reducing the need for external API calls. If the data is not in the cache, it is fetched from EuroPMC and then stored in the cache for future use.
The fetch.go file was removed because its functionality was redundant and no longer needed in the project. This helps to keep the codebase clean and maintainable.
… fetching The FetchPublication function has been refactored to first attempt to fetch the publication from cache. If the publication is not found in cache, it fetches from the EuroPMC endpoint and then stores the result in cache.
…r 404 status code The unused imports were removed to clean up the code and improve readability. The error handling for a 404 status code was removed because it was redundant and unnecessary. The function will now return an error for any status code that is not 200, which simplifies the error handling and makes the function more efficient.
…p function The context parameter was removed from the GetResp function as it was not being used. This simplifies the function signature and avoids confusion about the function's usage.
…ving cache handling The cache handling logic was removed from the Publication function in the publication.go file. This simplifies the function by reducing the number of error handling blocks and makes the function more readable. The cache handling is now done in the FetchPublication function, which abstracts the complexity away from the Publication function. This change is part of an effort to make the codebase more maintainable and easier to understand.
…with FetchPublication for better code reuse The FetchPublicationFromEuroPMC function was replaced with FetchPublication in multiple files to promote code reuse and maintainability. The error handling was also improved by adding more context to the error messages, making it easier to debug issues when they arise.
…etchGOAs and fetchOrganisms functions The context parameter was removed from fetchGOAs and fetchOrganisms functions as it was not being used, simplifying the function signatures. The function parameters in organism.go were broken down into multiple lines to improve readability and maintainability of the code.
…om GetResp function call The context import and argument were removed from the GetResp function call in the fetch_test.go file. This was done because the context was not being used within the function, thus removing it simplifies the function signature and the test.
…s from being tracked
…on call The fetchGOAs function was simplified by removing the context parameter, which was not being used. This makes the function call cleaner and easier to understand. The test for fetchGOAs was updated to reflect this change.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pulling 'fix/empty-publication into develop. Please review and merge.