-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…add migration scripts (#11322)
- Loading branch information
1 parent
be2edf0
commit 837960d
Showing
11 changed files
with
294 additions
and
118 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...client/java/teammates/client/scripts/DataMigrationForConstSumForceUnevenDistribution.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package teammates.client.scripts; | ||
|
||
import java.io.IOException; | ||
|
||
import com.googlecode.objectify.cmd.Query; | ||
|
||
import teammates.common.datatransfer.attributes.FeedbackQuestionAttributes; | ||
import teammates.common.datatransfer.questions.FeedbackConstantSumDistributePointsType; | ||
import teammates.common.datatransfer.questions.FeedbackConstantSumQuestionDetails; | ||
import teammates.common.datatransfer.questions.FeedbackQuestionType; | ||
import teammates.storage.entity.FeedbackQuestion; | ||
|
||
/** | ||
* Script to set distributePointsFor to DISTRIBUTE_ALL_UNEVENLY if forceUnevenDistribution is true. | ||
* | ||
* <p>See issue #8577. | ||
*/ | ||
public class DataMigrationForConstSumForceUnevenDistribution extends | ||
DataMigrationEntitiesBaseScript<FeedbackQuestion> { | ||
|
||
public static void main(String[] args) throws IOException { | ||
new DataMigrationForConstSumForceUnevenDistribution().doOperationRemotely(); | ||
} | ||
|
||
@Override | ||
protected Query<FeedbackQuestion> getFilterQuery() { | ||
return ofy().load().type(FeedbackQuestion.class) | ||
.filter("questionType =", FeedbackQuestionType.CONSTSUM.name()); | ||
} | ||
|
||
@Override | ||
protected boolean isPreview() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean isMigrationNeeded(FeedbackQuestion question) { | ||
FeedbackQuestionAttributes fqa = FeedbackQuestionAttributes.valueOf(question); | ||
FeedbackConstantSumQuestionDetails fcsqd = (FeedbackConstantSumQuestionDetails) fqa.getQuestionDetails(); | ||
|
||
return fcsqd.isForceUnevenDistribution() | ||
&& FeedbackConstantSumDistributePointsType.NONE.getDisplayedOption().equals(fcsqd.getDistributePointsFor()); | ||
} | ||
|
||
@Override | ||
protected void migrateEntity(FeedbackQuestion question) { | ||
FeedbackQuestionAttributes fqa = FeedbackQuestionAttributes.valueOf(question); | ||
FeedbackConstantSumQuestionDetails fcsqd = (FeedbackConstantSumQuestionDetails) fqa.getQuestionDetails(); | ||
|
||
fcsqd.setDistributePointsFor( | ||
FeedbackConstantSumDistributePointsType.DISTRIBUTE_ALL_UNEVENLY.getDisplayedOption()); | ||
|
||
fqa.setQuestionDetails(fcsqd); | ||
|
||
saveEntityDeferred(question); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
src/client/java/teammates/client/scripts/DataMigrationForNullCommentGiverType.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package teammates.client.scripts; | ||
|
||
import java.io.IOException; | ||
|
||
import com.googlecode.objectify.cmd.Query; | ||
|
||
import teammates.common.datatransfer.FeedbackParticipantType; | ||
import teammates.storage.entity.FeedbackResponseComment; | ||
|
||
/** | ||
* Script to set commentGiverType as INSTRUCTOR in all comments by instructor. | ||
* | ||
* <p>See issue #9083</p> | ||
*/ | ||
public class DataMigrationForNullCommentGiverType extends | ||
DataMigrationEntitiesBaseScript<FeedbackResponseComment> { | ||
|
||
public static void main(String[] args) throws IOException { | ||
new DataMigrationForNullCommentGiverType().doOperationRemotely(); | ||
} | ||
|
||
@Override | ||
protected Query<FeedbackResponseComment> getFilterQuery() { | ||
return ofy().load().type(FeedbackResponseComment.class) | ||
.filter("commentGiverType =", null); | ||
} | ||
|
||
@Override | ||
protected boolean isPreview() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean isMigrationNeeded(FeedbackResponseComment comment) { | ||
return comment.getCommentGiverType() == null; | ||
} | ||
|
||
@Override | ||
protected void migrateEntity(FeedbackResponseComment comment) { | ||
comment.setCommentGiverType(FeedbackParticipantType.INSTRUCTORS); | ||
comment.setIsCommentFromFeedbackParticipant(false); | ||
|
||
saveEntityDeferred(comment); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...ient/java/teammates/client/scripts/DataMigrationForSampleGoogleIdInStudentAttributes.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package teammates.client.scripts; | ||
|
||
import java.io.IOException; | ||
|
||
import com.googlecode.objectify.cmd.Query; | ||
|
||
import teammates.storage.entity.CourseStudent; | ||
|
||
/** | ||
* Script to remove google ID of {@link CourseStudent} if it is fake google ID. | ||
*/ | ||
public class DataMigrationForSampleGoogleIdInStudentAttributes | ||
extends DataMigrationEntitiesBaseScript<CourseStudent> { | ||
|
||
public static void main(String[] args) throws IOException { | ||
DataMigrationForSampleGoogleIdInStudentAttributes migrator = | ||
new DataMigrationForSampleGoogleIdInStudentAttributes(); | ||
migrator.doOperationRemotely(); | ||
} | ||
|
||
@Override | ||
protected Query<CourseStudent> getFilterQuery() { | ||
String sampleGoogleId = "alice.b.tmms.sampleData"; | ||
// Uncomment the google ID to be removed as necessary | ||
// sampleGoogleId = "benny.c.tmms.sampleData"; | ||
// sampleGoogleId = "charlie.d.tmms.sampleData"; | ||
// sampleGoogleId = "danny.e.tmms.sampleData"; | ||
// sampleGoogleId = "emma.f.tmms.sampleData"; | ||
// sampleGoogleId = "francis.g.tmms.sampleData"; | ||
// sampleGoogleId = "gene.h.tmms.sampleData"; | ||
// sampleGoogleId = "teammates.demo.instructor"; | ||
|
||
return ofy().load().type(CourseStudent.class) | ||
.filter("googleId =", sampleGoogleId); | ||
} | ||
|
||
@Override | ||
protected boolean isPreview() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean isMigrationNeeded(CourseStudent student) throws Exception { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void migrateEntity(CourseStudent student) throws Exception { | ||
student.setGoogleId(""); | ||
|
||
saveEntityDeferred(student); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/client/java/teammates/client/scripts/DataMigrationForTextQuestionRecommendedLength.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package teammates.client.scripts; | ||
|
||
import java.io.IOException; | ||
|
||
import com.googlecode.objectify.cmd.Query; | ||
|
||
import teammates.common.datatransfer.attributes.FeedbackQuestionAttributes; | ||
import teammates.common.datatransfer.questions.FeedbackQuestionType; | ||
import teammates.common.datatransfer.questions.FeedbackTextQuestionDetails; | ||
import teammates.storage.entity.FeedbackQuestion; | ||
|
||
/** | ||
* Script to set recommendedLength as null in all text questions whose recommendedLength is 0. | ||
* | ||
* <p>See issue #10677</p> | ||
*/ | ||
public class DataMigrationForTextQuestionRecommendedLength extends | ||
DataMigrationEntitiesBaseScript<FeedbackQuestion> { | ||
|
||
public static void main(String[] args) throws IOException { | ||
new DataMigrationForTextQuestionRecommendedLength().doOperationRemotely(); | ||
} | ||
|
||
@Override | ||
protected Query<FeedbackQuestion> getFilterQuery() { | ||
return ofy().load().type(FeedbackQuestion.class) | ||
.filter("questionType =", FeedbackQuestionType.TEXT.name()); | ||
} | ||
|
||
@Override | ||
protected boolean isPreview() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean isMigrationNeeded(FeedbackQuestion question) { | ||
FeedbackQuestionAttributes fqa = FeedbackQuestionAttributes.valueOf(question); | ||
FeedbackTextQuestionDetails ftqd = (FeedbackTextQuestionDetails) fqa.getQuestionDetails(); | ||
return ftqd.getRecommendedLength() != null && ftqd.getRecommendedLength() == 0; | ||
} | ||
|
||
@Override | ||
protected void migrateEntity(FeedbackQuestion question) { | ||
FeedbackQuestionAttributes fqa = FeedbackQuestionAttributes.valueOf(question); | ||
FeedbackTextQuestionDetails ftqd = (FeedbackTextQuestionDetails) fqa.getQuestionDetails(); | ||
ftqd.setRecommendedLength(null); | ||
|
||
fqa.setQuestionDetails(ftqd); | ||
|
||
saveEntityDeferred(fqa.toEntity()); | ||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.