-
Notifications
You must be signed in to change notification settings - Fork 0
Add database changelog for episode delay properties and refactor episode update logic #1249
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
Conversation
Summary of ChangesHello @Ziedelth, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the episode update mechanism by replacing a single, generic update delay with a more sophisticated system that applies different delays based on an anime's seasonal relevance. This allows for more frequent updates for current season anime and less frequent updates for older content, optimizing resource usage and data freshness. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the episode update logic to use more granular delay properties based on whether an episode belongs to the current, last, or other seasons. This is a good improvement for controlling the update frequency. The changes include updating the ConfigPropertyKey enum, refactoring the UpdateEpisodeMappingJob and EpisodeMappingService, and implementing the new query logic in EpisodeMappingRepository. A Liquibase changelog is added to migrate the database configuration.
I've provided a few suggestions to improve performance and maintainability:
- In
EpisodeMappingRepository, I've suggested usingNOT EXISTSinstead ofNOT INfor better query performance. - In
UpdateEpisodeMappingJob, I've pointed out a small inefficiency where a value is recalculated inside a loop. - For the Liquibase changelog, I've recommended combining the related database changes into a single atomic changeset.
Overall, the changes are well-structured and address the intended goal effectively.
|
|
||
| needUpdateEpisodes.forEach { mapping -> | ||
| updateEpisodeMapping(mapping, identifiers, allPreviousAndNext, lastImageUpdateDateTime, zonedDateTime, needRecalculate, needRefreshCache) | ||
| updateEpisodeMapping(mapping, identifiers, allPreviousAndNext, zonedDateTime.minusDays(configCacheService.getValueAsInt(ConfigPropertyKey.UPDATE_IMAGE_EPISODE_DELAY, 2).toLong()), zonedDateTime, needRecalculate, needRefreshCache) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| cb.not(animeJoin[Anime_.uuid].`in`(query.subquery(UUID::class.java).apply { | ||
| val subRoot = from(Anime::class.java) | ||
| select(subRoot[Anime_.uuid]) | ||
| .where(subRoot.join(Anime_.simulcasts)[Simulcast_.uuid] | ||
| .`in`(listOfNotNull(currentSimulcastUuid, lastSimulcastUuid))) | ||
| })), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better performance, it's recommended to use NOT EXISTS with a correlated subquery instead of NOT IN. NOT IN can be inefficient, especially with large subquery result sets, and can have surprising behavior with NULL values. NOT EXISTS is often optimized better by database engines.
cb.not(cb.exists(query.subquery(Int::class.java).apply {
val subRoot = from(Anime::class.java)
select(cb.literal(1))
where(
cb.equal(subRoot[Anime_.uuid], animeJoin[Anime_.uuid]),
subRoot.join(Anime_.simulcasts)[Simulcast_.uuid]
.`in`(listOfNotNull(currentSimulcastUuid, lastSimulcastUuid))
)
}))8993f85 to
bd0bb75
Compare
bd0bb75 to
ae0d652
Compare
No description provided.