elimu-ai / webapp

🖥 Web application for hosting Android applications and educational content
https://hin.elimu.ai
MIT License
30 stars 55 forks source link

refactor(dao) : LetterSound #1677 #1725

Closed SnehaHS65 closed 1 month ago

SnehaHS65 commented 1 month ago

closes #1677

The version of webapp in pom.xml is still 2.4.11 and the db migration script in this name already exists. If you could change the version, I can create db script.

coderabbitai[bot] commented 1 month ago

Walkthrough

The overall change involves renaming the LetterSoundCorrespondence entity to LetterSound throughout the codebase, updating class names, method signatures, imports, variable names, and references in both Java files and JSP files. Additionally, new classes and methods have been introduced to manage the updated entity effectively, alongside the creation of a scheduled task to track LetterSound usage counts.

Changes

File Path Change Summary
src/main/java/.../LetterSoundContributionEventDao.java, .../LetterSoundPeerReviewEventDao.java Updated import statements and method signatures to use LetterSound instead of LetterSoundCorrespondence.
src/main/java/.../LetterSoundDao.java, .../LetterSoundDaoJpa.java Changed the entity type from LetterSoundCorrespondence to LetterSound and adjusted method implementations accordingly.
src/main/java/.../LetterSoundContributionEventDaoJpa.java, .../LetterSoundDaoJpa.java Changed class imports and method parameter types from LetterSoundCorrespondence to LetterSound.
src/main/java/.../converters/StringToLetterSoundConverter.java New file introducing a converter class to convert String IDs to LetterSound entities using LetterSoundDao.
src/main/java/.../LetterSound.java, src/main/java/.../Word.java Renamed LetterSoundCorrespondence class to LetterSound and updated related fields and methods.
src/main/java/.../LetterSoundContributionEvent.java, .../LetterSoundPeerReviewEvent.java Updated class imports and property types from LetterSoundCorrespondence to LetterSound.
src/main/java/.../JpaToGsonConverter.java, .../LetterSoundsRestController.java Updated method signatures and object references to replace LetterSoundCorrespondence with LetterSound.
src/main/java/.../LetterSoundUsageCountScheduler.java, .../SoundUsageCountScheduler.java Introduced a new scheduled task for LetterSound usage counts and updated references from LetterSoundCorrespondence to LetterSound in the existing scheduler.
src/main/java/.../CsvContentExtractionHelper.java, .../DbContentImportHelper.java Renamed methods and data structures to handle LetterSound instead of LetterSoundCorrespondence.
src/main/java/.../MainContentController.java, .../LetterSoundCreateController.java Changed attribute names and method parameters to use LetterSound instead of LetterSoundCorrespondence.
src/main/java/.../LetterSoundEditController.java, .../LetterSoundListController.java Updated import statements, variable declarations, and method parameters to reference LetterSound.
src/main/webapp/.../create.jsp, .../edit.jsp Updated modelAttribute values and element IDs from letterSoundCorrespondence to letterSound.
src/test/java/.../WordContributionRestControllerTest.java Renamed test method and updated variable names and JSON object references to work with letterSounds instead of letterSoundCorrespondences.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LetterSoundUsageCountScheduler
    participant WordDao
    participant LetterSoundDao

    User->>LetterSoundUsageCountScheduler: Trigger usage count update
    LetterSoundUsageCountScheduler->>WordDao: Retrieve all Words
    WordDao-->>LetterSoundUsageCountScheduler: Return Word list
    LetterSoundUsageCountScheduler->>LetterSoundDao: Retrieve all LetterSounds
    LetterSoundDao-->>LetterSoundUsageCountScheduler: Return LetterSound list
    LetterSoundUsageCountScheduler->>LetterSoundDao: Update usage counts
    LetterSoundDao-->>LetterSoundUsageCountScheduler: Confirm update
    LetterSoundUsageCountScheduler-->>User: Usage counts updated

Assessment against linked issues

Objective Addressed Explanation
Rename LetterSoundCorrespondence to LetterSound (1677)
Update references in LetterSoundPeerReviewEvent (1677)
Update references in LetterSoundContributionEvent (1677)
Update Word to use LetterSound instead of LetterSoundCorrespondence (1677)
Ensure all usages reflect new class naming (1677) Some references may still exist in tests.

Recent review details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 9130589dc9cb948352b6f2259bdc7a359e248f44 and cc010bed154e976be791effe666358991e052f9e.
Files selected for processing (1) * src/main/resources/db/migration/2004022.sql (1 hunks)
Additional context used
Learnings (1)
Common learnings
``` Learnt from: venkatesh2k3 PR: elimu-ai/webapp#1682 File: src/main/java/ai/elimu/dao/LetterSoundContributionEventDao.java:13-13 Timestamp: 2024-07-06T17:37:44.413Z Learning: In the `LetterSoundContributionEventDao.java` file, the method signatures should use `LetterSoundContributionEvent` instead of `LetterSoundCorrespondenceContributionEvent` to maintain consistency with the renaming of entities. ```
Additional comments not posted (6)
src/main/resources/db/migration/2004022.sql (6)
`7-8`: **Ensure the table renaming is correct for `LetterSound_Letter`.** The command drops the `LetterSound_Letter` table if it exists and then renames `LetterSoundCorrespondence_Letter` to `LetterSound_Letter`. Ensure that this operation does not lead to data loss and that it is executed in the correct order. --- `19-20`: **Ensure column renaming is correct for `LetterSound_Sound`.** The command drops the `LetterSound_id` column and renames `LetterSoundCorrespondence_id` to `LetterSound_id` in the `LetterSound_Sound` table. Ensure that this operation does not lead to data loss and that it is executed in the correct order. --- `4-5`: **Ensure the table renaming is correct.** The command drops the `LetterSound` table if it exists and then renames `LetterSoundCorrespondence` to `LetterSound`. Ensure that this operation does not lead to data loss and that it is executed in the correct order.
Verification successful --- **Renaming of `LetterSoundCorrespondence` table is correct** The sequence of operations involving the `LetterSoundCorrespondence` table confirms that the table exists and is being manipulated correctly. The renaming operation to `LetterSound` is executed in the correct order and does not lead to data loss. - `src/main/resources/db/migration/2004022.sql`: `ALTER TABLE LetterSoundCorrespondence RENAME TO LetterSound;`
Scripts executed The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Verify the existence of the `LetterSoundCorrespondence` table before renaming. # Test: Search for the `LetterSoundCorrespondence` table. Expect: The table should exist before renaming. rg --type sql -A 5 $'CREATE TABLE `LetterSoundCorrespondence`' ``` Length of output: 63 --- Script: ```shell #!/bin/bash # Description: Verify the existence of the `LetterSoundCorrespondence` table before renaming by searching for any references to it. # Test: Search for any references to the `LetterSoundCorrespondence` table in SQL files. rg --type sql 'LetterSoundCorrespondence' ``` Length of output: 5786 --- Script: ```shell #!/bin/bash # Description: List all SQL migration files and their contents to verify the sequence of operations involving `LetterSoundCorrespondence`. # Test: List the contents of all SQL migration files. fd -e sql -x cat ``` Length of output: 63280
--- `10-11`: **Ensure the table renaming is correct for `LetterSound_Sound`.** The command drops the `LetterSound_Sound` table if it exists and then renames `LetterSoundCorrespondence_Sound` to `LetterSound_Sound`. Ensure that this operation does not lead to data loss and that it is executed in the correct order. --- `13-14`: **Ensure the table renaming is correct for `Word_LetterSound`.** The command drops the `Word_LetterSound` table if it exists and then renames `Word_LetterSoundCorrespondence` to `Word_LetterSound`. Ensure that this operation does not lead to data loss and that it is executed in the correct order. --- `16-17`: **Ensure column renaming is correct for `LetterSound_Letter`.** The command drops the `LetterSound_id` column and renames `LetterSoundCorrespondence_id` to `LetterSound_id` in the `LetterSound_Letter` table. Ensure that this operation does not lead to data loss and that it is executed in the correct order.
--- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 5.26316% with 108 lines in your changes missing coverage. Please review.

Project coverage is 15.19%. Comparing base (eb26209) to head (cc010be).

Files Patch % Lines
...ai/elimu/tasks/LetterSoundUsageCountScheduler.java 6.89% 27 Missing :warning:
.../ai/elimu/util/csv/CsvContentExtractionHelper.java 0.00% 19 Missing :warning:
...i/elimu/web/content/word/WordCreateController.java 7.69% 12 Missing :warning:
.../ai/elimu/web/content/word/WordEditController.java 0.00% 12 Missing :warning:
...limu/web/content/word/WordCsvExportController.java 0.00% 8 Missing :warning:
.../main/java/ai/elimu/dao/jpa/LetterSoundDaoJpa.java 12.50% 7 Missing :warning:
...logic/converters/StringToLetterSoundConverter.java 16.66% 5 Missing :warning:
...n/java/ai/elimu/util/db/DbContentImportHelper.java 0.00% 2 Missing :warning:
...tent/letter_sound/LetterSoundCreateController.java 0.00% 2 Missing :warning:
...t/letter_sound/LetterSoundCsvExportController.java 0.00% 2 Missing :warning:
... and 8 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1725 +/- ## ========================================= Coverage 15.19% 15.19% Complexity 450 450 ========================================= Files 249 249 Lines 7630 7630 Branches 801 801 ========================================= Hits 1159 1159 Misses 6421 6421 Partials 50 50 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jo-elimu commented 1 month ago

The version of webapp in pom.xml is still 2.4.11 and the db migration script in this name already exists. If you could change the version, I can create db script.

@Sneha65 Done: https://github.com/elimu-ai/webapp/releases

SnehaHS65 commented 1 month ago

@jo-elimu , can you please review and approve my PR

jo-elimu commented 1 month ago

@SnehaHS65 I applied some suggestions: https://github.com/elimu-ai/webapp/pull/1725/commits/40cf0e155b6925b14c548688e513dc9bffaa71f9

So please fetch the latest changes before you continue working on the branch.

SnehaHS65 commented 1 month ago

@SnehaHS65 I applied some suggestions: 40cf0e1

So please fetch the latest changes before you continue working on the branch.

@jo-elimu , Can you please check now?

SnehaHS65 commented 1 month ago

@SnehaHS65 See https://github.com/elimu-ai/webapp/pull/1725/files#r1678766292

@jo-elimu , when I fetched from main and merged, it says already up to date that's why I pushed. I don't know why this is happening.

SnehaHS65 commented 1 month ago

@SnehaHS65 See https://github.com/elimu-ai/webapp/pull/1725/files#r1678766292

@jo-elimu , when I fetched from main and merged, it says already up to date that's why I pushed. I don't know why this is happening.

@jo-elimu , the db script file for version 14 is also changed in main, now what would be the suitable thing to do? should I close this PR?

jo-elimu commented 1 month ago

the db script file for version 14 is also changed in main, now what would be the suitable thing to do? should I close this PR?

@SnehaHS65 You can rename the file so that it matches the current snapshot version on the main branch: https://github.com/elimu-ai/webapp/blob/main/pom.xml

SnehaHS65 commented 1 month ago

@jo-elimu , now all the files should be in sync with the Main branch, can you please review

jo-elimu commented 1 month ago

@jo-elimu , now all the files should be in sync with the Main branch, can you please review

Thank you, @SnehaHS65. I will test your code changes later today.

SnehaHS65 commented 1 month ago

Thank you, @SnehaHS65. I think these changes look good. Please merge, so that we can create a release and try out the migration script on the databases in production (Hindi + Tagalog).

@jo-elimu , Merged!!