Skip to content
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

General: Improve cleanup service #9851

Merged
merged 52 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3baba5d
add count dtos
coolchock Nov 16, 2024
c89b831
add count routes to AdminCleanupResource
coolchock Nov 16, 2024
a0a7ee4
add count methods to FeedbackCleanupRepository
coolchock Nov 16, 2024
a90946e
add count methods to LongFeedbackTextCleanupRepository
coolchock Nov 16, 2024
949762c
add count methods to ParticipantScoreCleanupRepository
coolchock Nov 16, 2024
0744a0e
add count methods to PlagiarismComparisonCleanupRepository
coolchock Nov 16, 2024
1f8cf77
remove redundant method
coolchock Nov 16, 2024
cd27c33
add count methods in RatingCleanupRepository
coolchock Nov 16, 2024
1ddb9f1
add count methods in ResultCleanupRepository
coolchock Nov 16, 2024
2443c45
add count methods in StudentScoreCleanupRepository
coolchock Nov 16, 2024
75fa78e
add count methods in TeamScoreCleanupRepository
coolchock Nov 16, 2024
f8c2641
add count methods in TextBlockCleanupRepository
coolchock Nov 16, 2024
7610d88
add methods to count affected entities to DataCleanupService
coolchock Nov 16, 2024
cbb287b
add interfaces and http methods in the data-cleanup.service.ts
coolchock Nov 16, 2024
7bf9e5f
add cleanup operation modal
coolchock Nov 16, 2024
177e192
add cleanup operation modal component
coolchock Nov 16, 2024
ab18d13
add tooltip in the cleanup-service
coolchock Nov 16, 2024
a207220
move methods from cleanup-service.component.ts
coolchock Nov 16, 2024
211cc9e
add english translations
coolchock Nov 16, 2024
3f59887
Merge branch 'refs/heads/develop' into general/cleanup-service-improv…
coolchock Nov 22, 2024
cee7692
add german translations
coolchock Nov 26, 2024
be7224c
disable button if there are no entities to delete
coolchock Nov 26, 2024
61ea65f
add count methods integration tests
coolchock Nov 26, 2024
e21f8eb
update clenaup-service.service.spec.ts
coolchock Nov 27, 2024
f74abe9
adjust cleanup-service.component.spec.ts
coolchock Nov 27, 2024
6c74d96
change @Input to input<>
coolchock Nov 27, 2024
3019825
add modal test
coolchock Nov 27, 2024
6088378
update javadoc
coolchock Nov 27, 2024
14bf289
revert change
coolchock Nov 27, 2024
db9b4b6
adjust translation
coolchock Nov 27, 2024
1632130
migrate to new input
coolchock Nov 27, 2024
bc66696
migrate tests to input<>
coolchock Nov 27, 2024
530914e
fix modal test
coolchock Nov 27, 2024
ced1ea5
Merge branch 'develop' into chore/cleanup-service-improvements
coolchock Nov 30, 2024
ed9afbf
add routes for submission versions
coolchock Dec 9, 2024
5cfb68a
add submission versions dto
coolchock Dec 9, 2024
7b05e4c
add submission version cleanup repository
coolchock Dec 9, 2024
39a0900
add cleanup methods for submission versions
coolchock Dec 9, 2024
e6aaa46
add requests for submission version cleanup methods
coolchock Dec 9, 2024
020bc20
add submission versions operation to component
coolchock Dec 9, 2024
dadbf9e
add submission versions methods to modal
coolchock Dec 9, 2024
3c2273a
resolve translations issues
coolchock Dec 9, 2024
f67ab93
convert ZonedDateTime to Instant
coolchock Dec 9, 2024
5050da9
add translations for submission versions
coolchock Dec 9, 2024
6c8b4a9
add tests
coolchock Dec 12, 2024
aaae31d
fix style issues
coolchock Dec 12, 2024
5247af8
fix console errors
coolchock Dec 16, 2024
cee41c6
make tooltips more descriptive
coolchock Dec 16, 2024
f7f021e
replace null checks
coolchock Dec 17, 2024
8fcf1db
improve tooltips
coolchock Dec 17, 2024
b29036c
add annotation to DTOs
coolchock Dec 17, 2024
fc01ba1
Merge branch 'develop' into chore/cleanup-service-improvements
coolchock Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ WHERE f.result IN (
""")
int deleteFeedbackForOrphanResults();

/**
* Counts {@link Feedback} entries where the associated {@link Result} has no submission and no participation.
*
* @return the number of entities that would be deleted
*/
@Query("""
SELECT COUNT(f)
FROM Feedback f
WHERE f.result IN (
SELECT r
FROM Result r
WHERE r.submission IS NULL
AND r.participation IS NULL
)
""")
int countFeedbackForOrphanResults();

/**
* Deletes {@link Feedback} entries with a {@code null} result.
*
Expand All @@ -56,6 +73,18 @@ WHERE f.result IN (
""")
int deleteOrphanFeedback();

/**
* Counts {@link Feedback} entries with a {@code null} result.
*
* @return the number of entities that would be deleted
*/
@Query("""
SELECT COUNT(f)
FROM Feedback f
WHERE f.result IS NULL
""")
int countOrphanFeedback();

/**
* Deletes {@link Feedback} entries associated with rated {@link Result} that are not the latest rated result
* for a {@link Participation}, within courses conducted between the specified date range.
Expand Down Expand Up @@ -89,6 +118,36 @@ SELECT MAX(r2.id)
""")
int deleteOldFeedbackThatAreNotLatestRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Counts {@link Feedback} entries associated with rated {@link Result} that are not the latest rated result
* for a {@link Participation}, within courses conducted between the specified date range.
*
* @param deleteFrom the start date for selecting courses
* @param deleteTo the end date for selecting courses
* @return the number of entities that would be deleted
*/
@Query("""
SELECT COUNT(f)
FROM Feedback f
WHERE f.result IN (
coolchock marked this conversation as resolved.
Show resolved Hide resolved
SELECT r
FROM Result r
LEFT JOIN r.participation p
LEFT JOIN p.exercise e
LEFT JOIN e.course c
WHERE r.id NOT IN (
SELECT MAX(r2.id)
FROM Result r2
WHERE r2.participation.id = p.id
AND r2.rated = TRUE
)
AND r.rated = TRUE
AND c.endDate < :deleteTo
AND c.startDate > :deleteFrom
)
""")
int countOldFeedbackThatAreNotLatestRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Deletes non-rated {@link Feedback} entries that are not the latest non-rated result, where the associated course's start and end dates
* are between the specified date range.
Expand Down Expand Up @@ -120,4 +179,33 @@ SELECT MAX(r2.id)
)
""")
int deleteOldNonRatedFeedbackWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Counts non-rated {@link Feedback} entries that are not the latest non-rated result, where the associated course's start and end dates
* are between the specified date range.
*
* @param deleteFrom the start date for selecting courses
* @param deleteTo the end date for selecting courses
* @return the number of entities that would be deleted
*/
@Query("""
SELECT COUNT(f)
FROM Feedback f
WHERE f.result IN (
SELECT r
FROM Result r
LEFT JOIN r.participation p
LEFT JOIN p.exercise e
LEFT JOIN e.course c
WHERE r.id NOT IN (
SELECT MAX(r2.id)
FROM Result r2
WHERE r2.participation.id = p.id
)
AND r.rated = FALSE
AND c.endDate < :deleteTo
AND c.startDate > :deleteFrom
)
""")
int countOldNonRatedFeedbackWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);
coolchock marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ WHERE lft.feedback.id IN (
""")
int deleteLongFeedbackTextForOrphanResult();

/**
* Counts {@link LongFeedbackText} entries linked to {@link Feedback} where the associated
* {@link Result} has no participation and no submission.
*
* @return the number of entities that would be deleted
*/
@Query("""
SELECT COUNT(lft)
FROM LongFeedbackText lft
WHERE lft.feedback.id IN (
SELECT f.id
FROM Feedback f
WHERE f.result.participation IS NULL
AND f.result.submission IS NULL
)
""")
int countLongFeedbackTextForOrphanResult();

/**
* Deletes {@link LongFeedbackText} linked to {@link Feedback} with a {@code null} result.
*
Expand All @@ -61,6 +79,22 @@ WHERE lft.feedback IN (
""")
int deleteLongFeedbackTextForOrphanedFeedback();

/**
* Counts {@link LongFeedbackText} linked to {@link Feedback} with a {@code null} result.
*
* @return the number of entities that would be deleted
*/
@Query("""
SELECT COUNT(lft)
FROM LongFeedbackText lft
WHERE lft.feedback IN (
SELECT f
FROM Feedback f
WHERE f.result IS NULL
)
""")
int countLongFeedbackTextForOrphanedFeedback();
coolchock marked this conversation as resolved.
Show resolved Hide resolved

/**
* Deletes {@link LongFeedbackText} entries associated with rated {@link Result} that are not the latest rated result
* for a {@link Participation}, within courses conducted between the specified date range.
Expand Down Expand Up @@ -95,6 +129,37 @@ SELECT MAX(r2.id)
""")
int deleteLongFeedbackTextForRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Counts {@link LongFeedbackText} entries associated with rated {@link Result} that are not the latest rated result
* for a {@link Participation}, within courses conducted between the specified date range.
*
* @param deleteFrom the start date for selecting courses
* @param deleteTo the end date for selecting courses
* @return the number of entities that would be deleted
*/
@Query("""
SELECT COUNT(lft)
FROM LongFeedbackText lft
WHERE lft.feedback IN (
SELECT f
FROM Feedback f
LEFT JOIN f.result r
LEFT JOIN r.participation p
LEFT JOIN p.exercise e
LEFT JOIN e.course c
WHERE f.result.id NOT IN (
SELECT MAX(r2.id)
FROM Result r2
WHERE r2.participation.id = p.id
AND r2.rated = TRUE
)
AND c.endDate < :deleteTo
AND c.startDate > :deleteFrom
AND r.rated = TRUE
)
""")
int countLongFeedbackTextForRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Deletes {@link LongFeedbackText} entries linked to non-rated {@link Feedback} that are not the latest non-rated result where the associated course's start
* and end dates are between the specified date range.
Expand Down Expand Up @@ -128,4 +193,35 @@ SELECT MAX(r2.id)
)
""")
int deleteLongFeedbackTextForNonRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Counts {@link LongFeedbackText} entries linked to non-rated {@link Feedback} that are not the latest non-rated result where the associated course's start
* and end dates are between the specified date range.
*
* @param deleteFrom the start date for selecting courses
* @param deleteTo the end date for selecting courses
* @return the number of entities that would be deleted
*/
@Query("""
SELECT COUNT(lft)
FROM LongFeedbackText lft
WHERE lft.feedback IN (
SELECT f
FROM Feedback f
LEFT JOIN f.result r
LEFT JOIN r.participation p
LEFT JOIN p.exercise e
LEFT JOIN e.course c
WHERE f.result.id NOT IN (
SELECT MAX(r2.id)
FROM Result r2
WHERE r2.participation.id = p.id
AND r2.rated = FALSE
)
AND r.rated = FALSE
AND c.endDate < :deleteTo
AND c.startDate > :deleteFrom
)
""")
int countLongFeedbackTextForNonRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,37 @@ SELECT MAX(r2.id)
""")
int deleteParticipantScoresForNonLatestLastResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Counts {@link ParticipantScore} entries where the associated {@link Result} is not the latest rated result
* for a {@link Participation}, within courses conducted between the specified date range.
*
* @param deleteFrom the start date for selecting courses
* @param deleteTo the end date for selecting courses
* @return the number of entities that would be deleted upon execution of the cleanup operation
*
*/
@Query("""
SELECT COUNT(ps)
FROM ParticipantScore ps
WHERE ps.lastResult IN (
SELECT r
FROM Result r
LEFT JOIN r.participation p
LEFT JOIN p.exercise e
LEFT JOIN e.course c
WHERE r.id NOT IN (
SELECT MAX(r2.id)
FROM Result r2
WHERE r2.participation.id = p.id
AND r2.rated = TRUE
)
AND r.rated = TRUE
AND c.endDate < :deleteTo
AND c.startDate > :deleteFrom
)
""")
int countParticipantScoresForNonLatestLastResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Deletes {@link ParticipantScore} entries where the associated last rated {@link Result} is not the latest rated result
* for a {@link Participation}, within courses conducted between the specified date range.
Expand Down Expand Up @@ -90,6 +121,36 @@ SELECT MAX(r2.id)
""")
int deleteParticipantScoresForNonLatestLastRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Counts {@link ParticipantScore} entries where the associated last rated {@link Result} is not the latest rated result
* for a {@link Participation}, within courses conducted between the specified date range.
*
* @param deleteFrom the start date for selecting courses
* @param deleteTo the end date for selecting courses
* @return the number of entities that would be deleted upon execution of the cleanup operation
*/
@Query("""
SELECT COUNT(ps)
FROM ParticipantScore ps
WHERE ps.lastRatedResult IN (
SELECT r
FROM Result r
LEFT JOIN r.participation p
LEFT JOIN p.exercise e
LEFT JOIN e.course c
WHERE r.id NOT IN (
SELECT MAX(r2.id)
FROM Result r2
WHERE r2.participation.id = p.id
AND r2.rated = TRUE
)
AND r.rated = TRUE
AND c.endDate < :deleteTo
AND c.startDate > :deleteFrom
)
""")
int countParticipantScoresForNonLatestLastRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Deletes {@link ParticipantScore} entries where the associated {@link Result} is not the latest result and is non-rated,
* and the course's start and end dates are between the specified date range.
Expand Down Expand Up @@ -122,6 +183,36 @@ SELECT MAX(r2.id)
""")
int deleteParticipantScoresForLatestNonRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Counts {@link ParticipantScore} entries where the associated {@link Result} is not the latest result and is non-rated,
* and the course's start and end dates are between the specified date range.
*
* @param deleteFrom the start date for selecting courses
* @param deleteTo the end date for selecting courses
* @return the number of entities that would be deleted upon execution of the cleanup operation
*/
@Query("""
SELECT COUNT(ps)
FROM ParticipantScore ps
WHERE ps.lastResult IN (
SELECT r
FROM Result r
LEFT JOIN r.participation p
LEFT JOIN p.exercise e
LEFT JOIN e.course c
WHERE r.id NOT IN (
SELECT MAX(r2.id)
FROM Result r2
WHERE r2.participation.id = p.id
AND r2.rated = FALSE
)
AND r.rated = FALSE
AND c.endDate < :deleteTo
AND c.startDate > :deleteFrom
)
""")
int countParticipantScoresForLatestNonRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Deletes {@link ParticipantScore} entries where the associated {@link Result} is not latest and is non-rated, even though
* it is marked as the last rated result, to prevent potential integrity violations.
Expand Down Expand Up @@ -155,4 +246,34 @@ SELECT MAX(r2.id)
)
""")
int deleteParticipantScoresForNonRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);

/**
* Counts {@link ParticipantScore} entries where the associated {@link Result} is not latest and is non-rated, even though
* it is marked as the last rated result.
*
* @param deleteFrom the start date for selecting courses
* @param deleteTo the end date for selecting courses
* @return the number of entities that would be deleted upon execution of the cleanup operation
*/
@Query("""
SELECT COUNT(ps)
FROM ParticipantScore ps
WHERE ps.lastRatedResult IN (
SELECT r
FROM Result r
LEFT JOIN r.participation p
LEFT JOIN p.exercise e
LEFT JOIN e.course c
WHERE r.id NOT IN (
SELECT MAX(r2.id)
FROM Result r2
WHERE r2.participation.id = p.id
AND r2.rated = FALSE
)
AND r.rated = FALSE
AND c.endDate < :deleteTo
AND c.startDate > :deleteFrom
)
""")
int countParticipantScoresForNonRatedResultsWhereCourseDateBetween(@Param("deleteFrom") ZonedDateTime deleteFrom, @Param("deleteTo") ZonedDateTime deleteTo);
}
Loading
Loading