-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[#12048] Patch Usage Statistics Migration #12889
[#12048] Patch Usage Statistics Migration #12889
Conversation
Add SQL query to patch the data migration script
One problem with the patching right now is that we still have to scan through all the datastore entities, and only filter in memory. This is because filtering in datastore requires we create an index. Probably not needed for now since the number of entities is relatively small, and scanning datastore is relatively fast, but it may be needed next time for course entities. |
CriteriaBuilder cb = HibernateUtil.getCriteriaBuilder(); | ||
CriteriaQuery<Instant> cq = cb.createQuery(Instant.class); | ||
Root<UsageStatistics> root = cq.from(UsageStatistics.class); | ||
cq.select(cb.greatest(root.<Instant>get("createdAt"))); |
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.
I think this should be changed to startTime
since createdAt
is what time the entity is created in the SQL DB. UsageStatistics are created one per hour, so this startTime should be unique as well
Fix bug for createdAt
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.
LGTM!
Part of #12048
Outline of Solution
SELECT MAX(start_time) FROM usage_statistics;
and then copy paste the string to the START_TIME_STRING. (Is it possible to do the query in the script?)