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

Up 4621 Add Date When Portlet Rating Was Made #1065

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

phillips1021
Copy link

Checklist
Description of change

Added date a portlet rating was made and added new end points for the MarketPlaceRESTController so we can get portlet ratings done within the past X days

a certain number of days - for example all ratings done within last
30 days or all ratings for a specific portlet within last 30 days
see: https://issues.jasig.org/browse/UP-4636
… done within

a certain number of days - for example all ratings done within last
30 days or all ratings for a specific portlet within last 30 days
see: https://issues.jasig.org/browse/UP-4636
portlet rating that can then be returned by the REST end point defined
in MarketplaceRESTController
see: https://issues.jasig.org/browse/UP-4636
a number of days for searching portlet ratings
Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phillips1021! 🙇
Keeping track of the date-time of ratings is a nice addition to uPortal. 👍

If you have't already, could you file a license agreement with Apereo? https://www.apereo.org/licensing/agreements


Continued from #1064

Looks better, thanks for running the Google code style formatter! 🙇


📓 its helpful to note, that additional commits pushed to a git branch with an open pull request, will automatically be included as part of the pull request.

"comment for "
+ ratingPK.getPortletDefinition().getFName());
marketplaceRatingDao.createOrUpdateRating(rating);
i = i + 20;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Could i be named something numberOfDaysBack to give some additional clarity on the purpose?
❓ maybe 20 could become something like final int TEST_DATE_INCREMENT = 20?

continued from #1064 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made this change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phillips1021!Ccould the change also be pushed to GitHub?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was pushed to GitHub previously - see: phillips1021@d6764ce

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 395 uses the same constant for the same purpose.

public Set<IMarketplaceRating> getAllRatingsInLastXDays(int numberOfDaysBack) {

final Calendar queryDate = Calendar.getInstance();
queryDate.add(Calendar.DAY_OF_YEAR, 0 - numberOfDaysBack);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Could the Java 8 Time processing utils be used to simplify/clarify the code?
http://www.baeldung.com/migrating-to-java-8-date-time-api

continued from #1064 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made this change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phillips1021!Ccould the change also be pushed to GitHub?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was pushed to GitHub previously - see: phillips1021@3ec0bb9

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 358 uses the same subtract operation and has not been updated.


for (ILocalAccountPerson person : personList) {
today.add(Calendar.DAY_OF_YEAR, 0 - numberOfDaysBack);
System.out.println(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📓 System.out.format may be able to help here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the println statement - it was not really needed

@ChristianMurphy ChristianMurphy added this to the 5.1.0 milestone Dec 7, 2017
Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @phillips1021! 🙇

@@ -33,6 +34,9 @@
@Column(name = "REVIEW", length = REVIEW_MAX_LENGTH)
private String review;

@Column(name = "RATINGDATE")
private Date ratingDate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great addition, but (for a few reasons) we need to proceed with care.

One of those reasons is that this enhancement includes a database schema change.

Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some additional questions:

* @param daysBack - number of days back to search for portlet ratings
* @return
*/
@RequestMapping(value = "/marketplace/{daysBack}/getRatings", method = RequestMethod.GET)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ what if data from two weeks ago to last week is wanted?
Perhaps supporting a date range could future proof the API more?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Christian - if you or others would like to add more end points please do so. I'm done with this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add v5-1 to the URI.

public MarketplaceEntryRating(int rating, String review) {
this.rating = rating;
this.review = review;
}

private int rating;
private String review;
private String user;
private String portletName;
private Date ratingDate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is the column automatically created?
❓ How are missing dates handled?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your questions - the values will be null if not provided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working to understand how this should be versioned, if this will be SemVer minor or SemVer major.

The first question has to do with if this code is run on an existing database, from before this column is added, does HSQL automatically add the column or does a manual migration have to be run.

For the second, when legacy data is brought in with date being null, does the code have a graceful fllaback? or will it NPE?

Copy link
Author

@phillips1021 phillips1021 Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to test this update but I think it will require a manual migration.

I'll run the current branch locally and do some ratings of portlets.

Then I'll run my branch with the same HSQL database.

How do I run my branch locally with uPortal-Start?

I don't think I introduced any code that depends on ratingDate having a value but I will double check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I run my branch locally with uPortal-Start?

From the branch on uPortal ./gradlew install, this will build uPortal and create a snapshot on maven local.
Then head over to uPortal-start update gradle.properties to have uPortalVersion=5.0.3-SNAPSHOT.
Then run uPortal-start as usual, it will pull from the mavel local version.

📓 further updates to uPortal branch will require running ./gradlew install on the uPortal side again.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is how I tested

Ran uPortal-start with 5.0.1 version of uPortal

Created a few ratings as student and staff user

Built and installed locally my forked version of uPortal that includes adding RatingDate and new REST end points for market place controller.

Changed uPortal-start to use 5.0.3-SNAPSHOT and redeployed to Tomcat

Viewing any previous ratings or trying to create new ratings fails with SQL Exception due to missing RATINGDATE column in up_portlet_rating table

Added RATINGDATE column to up_portlet_rating table in HSQL database running locally using Squirrel SQL Client

Now can view previous ratings and can create new ratings

Tested new end points (e.g. http://localhost:8080/uPortal/api/marketplace/calendar/30/getRatings and http://localhost:8080/uPortal/api/marketplace/30/getRatings) and verified they work correctly.

Tested previous end points (e.g. http://localhost:8080/uPortal/api/marketplace/snooper/getRating and http://localhost:8080/uPortal/api/v5-0/marketplace/weather/ratings) and verified they work as before.

No Null Pointer Exceptions were generated when accessing ratings that were done previously and do not have a RATINGDATE value.

What is uPortal's process for updating the database schema to support a new release?

Do you feel this must be a major semantic version update (e.g. 6.X.X) due to the change in the database schema?

Bruce

Copy link
Member

@ChristianMurphy ChristianMurphy Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phillips1021 ! 🙇


What is uPortal's process for updating the database schema to support a new release?

Whenever possible an automated migration path is provided. When an automated process is not possible a notice is added in the release notes describing the manual steps to migrate.

My understanding is import/export is frequently used for helping with migrations, @drewwills would be able to elaborate more on that.


Do you feel this must be a major semantic version update (e.g. 6.X.X) due to the change in the database schema?

short answer
There is still ongoing discussion on if/how the DB schema included in the API.
Personally, I lean towards yes, which means this would be SemVer major (6.0).
I think this could be made SemVer minor by providing a default value if there is a Null.

long answer
uPortal is still in a monolithic repo, with monolithic versioning, which leads to some ambiguity around, section 1 of the SemVer Spec

Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it should be precise and comprehensive.

uPortal hasn't finished clearly defining what is included as an API.

There is a colorable argument that the project is a monolith, that database is intended for internal usage only, and therefore is outside semantic versioning.
There is also a colorable argument that the subprojects in the monorepo are independent, each exposes its own API, whenever one of the subproject API's is adds a new required element or removes an element, the Major version should be incremented.

I lean toward the former view. Meaning changes to the API that add a new required element to the API should be SemVer major.
Making the column optional could bring this back to SemVer minor.

@ChristianMurphy ChristianMurphy modified the milestones: 5.1.0, 6.0.0 Dec 15, 2017
* @return
*/
@RequestMapping(
value = "/marketplace/{fname}/{daysBack}/getRatings",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add v5-1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants