-
Notifications
You must be signed in to change notification settings - Fork 273
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
base: master
Are you sure you want to change the base?
Changes from all commits
03a2d59
19509d1
24d2f54
b0d5f28
185eeda
abb4656
b0756f5
9f91d4a
44bd696
994261e
6b1df42
99396e2
21d30eb
2587721
3ec0bb9
d6764ce
6545dad
136a235
19d516b
a094ddb
cdecd30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,4 +165,72 @@ public ModelAndView saveUserRating( | |
return new ModelAndView( | ||
"json", "rating", new MarketplaceEntryRating(Integer.parseInt(rating), review)); | ||
} | ||
|
||
/** | ||
* Get all ratings done on portlets since daysBack ago. | ||
* | ||
* @param request | ||
* @param daysBack - number of days back to search for portlet ratings | ||
* @return | ||
*/ | ||
@RequestMapping(value = "/marketplace/{daysBack}/getRatings", method = RequestMethod.GET) | ||
public ModelAndView getPortletRatings(HttpServletRequest request, @PathVariable int daysBack) { | ||
|
||
Set<IMarketplaceRating> portlets = marketplaceRatingDAO.getAllRatingsInLastXDays(daysBack); | ||
|
||
List<MarketplaceEntryRating> ratings = new ArrayList<>(); | ||
|
||
for (IMarketplaceRating portlet : portlets) { | ||
|
||
MarketplaceEntryRating portletRating = | ||
new MarketplaceEntryRating( | ||
portlet.getMarketplaceRatingPK().getUserName(), | ||
portlet.getMarketplaceRatingPK().getPortletDefinition().getName(), | ||
portlet.getMarketplaceRatingPK().getPortletDefinition().getFName(), | ||
portlet.getRating(), | ||
portlet.getReview(), | ||
portlet.getRatingDate()); | ||
|
||
ratings.add(portletRating); | ||
} | ||
|
||
return new ModelAndView("json", "ratings", ratings); | ||
} | ||
|
||
/** | ||
* Get all ratings done on a specific portlet since daysBack ago. | ||
* | ||
* @param request | ||
* @param fname - portlet fname | ||
* @param daysBack - number of days back to search for portlet ratings | ||
* @return | ||
*/ | ||
@RequestMapping( | ||
value = "/marketplace/{fname}/{daysBack}/getRatings", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to add |
||
method = RequestMethod.GET | ||
) | ||
public ModelAndView getPortletRatings( | ||
HttpServletRequest request, @PathVariable String fname, @PathVariable int daysBack) { | ||
|
||
Set<IMarketplaceRating> portlets = | ||
marketplaceRatingDAO.getAllRatingsForPortletInLastXDays(daysBack, fname); | ||
|
||
List<MarketplaceEntryRating> ratings = new ArrayList<>(); | ||
|
||
for (IMarketplaceRating portlet : portlets) { | ||
|
||
MarketplaceEntryRating portletRating = | ||
new MarketplaceEntryRating( | ||
portlet.getMarketplaceRatingPK().getUserName(), | ||
portlet.getMarketplaceRatingPK().getPortletDefinition().getName(), | ||
portlet.getMarketplaceRatingPK().getPortletDefinition().getFName(), | ||
portlet.getRating(), | ||
portlet.getReview(), | ||
portlet.getRatingDate()); | ||
|
||
ratings.add(portletRating); | ||
} | ||
|
||
return new ModelAndView("json", "ratings", ratings); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,56 @@ | |
*/ | ||
package org.apereo.portal.rest.layout; | ||
|
||
import java.util.Date; | ||
|
||
public class MarketplaceEntryRating { | ||
|
||
public MarketplaceEntryRating() {} | ||
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Is the column automatically created? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
From the branch on uPortal 📓 further updates to uPortal branch will require running There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @phillips1021 ! 🙇
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.
short answer long answer
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. I lean toward the former view. Meaning changes to the API that add a new required element to the API should be SemVer major. |
||
private String portletFName; | ||
|
||
public MarketplaceEntryRating( | ||
String user, | ||
String portletName, | ||
String portletFName, | ||
int rating, | ||
String review, | ||
Date ratingDate) { | ||
this.user = user; | ||
this.portletName = portletName; | ||
this.portletFName = portletFName; | ||
this.rating = rating; | ||
this.review = review; | ||
this.ratingDate = ratingDate; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MarketplaceEntryRating{" | ||
+ "rating=" | ||
+ rating | ||
+ ", review=" | ||
+ review | ||
+ ", user=" | ||
+ user | ||
+ ", portletName=" | ||
+ portletName | ||
+ ", ratingDate=" | ||
+ ratingDate | ||
+ ", portletFName=" | ||
+ portletFName | ||
+ '}'; | ||
} | ||
|
||
public int getRating() { | ||
return rating; | ||
|
@@ -39,4 +80,36 @@ public String getReview() { | |
public void setReview(String review) { | ||
this.review = review; | ||
} | ||
|
||
public String getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(String user) { | ||
this.user = user; | ||
} | ||
|
||
public String getPortletName() { | ||
return portletName; | ||
} | ||
|
||
public void setPortletName(String portletName) { | ||
this.portletName = portletName; | ||
} | ||
|
||
public Date getRatingDate() { | ||
return ratingDate; | ||
} | ||
|
||
public void setRatingDate(Date ratingDate) { | ||
this.ratingDate = ratingDate; | ||
} | ||
|
||
public String getPortletFName() { | ||
return portletFName; | ||
} | ||
|
||
public void setPortletFName(String portletFName) { | ||
this.portletFName = portletFName; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
*/ | ||
package org.apereo.portal.portlet.dao.jpa; | ||
|
||
import java.util.Date; | ||
import javax.persistence.Column; | ||
import javax.persistence.EmbeddedId; | ||
import javax.persistence.Entity; | ||
|
@@ -33,6 +34,9 @@ class MarketplaceRatingImpl implements IMarketplaceRating { | |
@Column(name = "REVIEW", length = REVIEW_MAX_LENGTH) | ||
private String review; | ||
|
||
@Column(name = "RATINGDATE") | ||
private Date ratingDate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
@Override | ||
public MarketplaceRatingPK getMarketplaceRatingPK() { | ||
return marketplaceRatingPK; | ||
|
@@ -69,12 +73,21 @@ public void setRating(int rating) { | |
this.rating = rating; | ||
} | ||
|
||
public Date getRatingDate() { | ||
return ratingDate; | ||
} | ||
|
||
public void setRatingDate(Date ratingDate) { | ||
this.ratingDate = ratingDate; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this) | ||
.append("RatingPK: ", this.marketplaceRatingPK) | ||
.append("Rating: ", this.rating) | ||
.append("Review: ", this.review) | ||
.append("Date: ", this.ratingDate) | ||
.toString(); | ||
} | ||
} |
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.
❓ what if data from two weeks ago to last week is wanted?
Perhaps supporting a date range could future proof the API more?
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.
Christian - if you or others would like to add more end points please do so. I'm done with this.
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'd like to add
v5-1
to the URI.