fixes Incident #21002 does not load recent posts and likes

master
Massimiliano Assante 3 years ago
parent a4c378aa93
commit e8c87df860

@ -1,10 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="user-statistics-portlet">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="java-output-path" value="/user-statistics/target/user-statistics-portlet-0.0.1-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="user-statistics"/>
</wb-module>
</project-modules>

@ -9,8 +9,23 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
Ported to git
Feature #21008: UserStatistics portlet: Remove number of comments done and got indicator
## [v2.2.0] - 2017-02-20"
## [v1.0.0] - 2015-10-21
Added storage Quota information
## [v2.1.0] - 2016-10-02
Posts related to some statistics are now retrievable on the demand
## [v2.0.0] - 2016-04-02
Ported to Liferay 6.2
Minor bug fix: long vre's name managed properly(Bug #2042)
## [v1.0.0] - 2015-12-09
First release

@ -1 +0,0 @@
${gcube.license}

@ -1,62 +0,0 @@
The gCube System - ${name}
--------------------------------------------------
${description}
${gcube.description}
${gcube.funding}
Version
--------------------------------------------------
${version} (${buildDate})
Please see the file named "changelog.xml" in this directory for the release notes.
Authors
--------------------------------------------------
* Costantino Perciante (costantino.perciante@isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Maintainers
-----------
* Costantino Perciante (costantino.perciante@isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Download information
--------------------------------------------------
Source code is available from SVN:
${scm.url}
Binaries can be downloaded from the gCube website:
${gcube.website}
Installation
--------------------------------------------------
Installation documentation is available on-line in the gCube Wiki:
${gcube.wikiRoot}
Documentation
--------------------------------------------------
Documentation is available on-line in the gCube Wiki:
${gcube.wikiRoot}
Support
--------------------------------------------------
Bugs and support requests can be reported in the gCube issue tracking tool:
${gcube.issueTracking}
Licensing
--------------------------------------------------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

@ -1,30 +0,0 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.user-statistics.2-2-0"
date="2017-02-20">
<Change>Added storage Quota information</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.user-statistics.2-1-1"
date="2016-12-02">
<Change>Minor fixes</Change>
<Change>Removed asl session</Change>
<Change>Moved to Liferay logging system</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.user-statistics.2-1-0"
date="2016-10-02">
<Change>Feeds related to some statistics are now retrievable on the
demand</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.user-statistics.2-0-0"
date="2016-04-02">
<Change>Ported to Liferay 6.2</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.user-statistics.1-0-1"
date="2016-01-22">
<Change>Minor bug fix: long vre's name managed properly(Bug #2042)
</Change>
</Changeset>
<Changeset component="org.gcube.portlet.user-statistics.1-0-0"
date="2015-12-9">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

@ -1,31 +0,0 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${build.finalName}.${project.packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Service</Type>
<Profile>
<Description>${description}</Description>
<Class>PortletUser</Class>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>target/${build.finalName}.war</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>user-statistics</artifactId>
<packaging>war</packaging>
<version>2.3.0-SNAPSHOT</version>
<version>2.3.0</version>
<name>User statistics portlet</name>
<description>
User statistics portlet shows main user's statistics.
@ -48,7 +48,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.0-SNAPSHOT</version>
<version>3.6.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>

@ -1,10 +1,5 @@
package org.gcube.portlet.user.userstatisticsportlet.client;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapter;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusEvent;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusListener;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.ShowUserStatisticAction;
@ -37,6 +32,11 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapter;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusEvent;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusListener;
/**
* Panel to show received user's statistics
*
@ -95,11 +95,6 @@ public class StatisticsPanel extends Composite {
private final static String TOOLTIP_LIKES_GOT_VRE = "Likes got during the last year in this VRE";
private final static String TOOLTIP_LIKES_DONE = "Likes done during the last year";
private final static String TOOLTIP_LIKES_DONE_VRE = "Likes done during the last year in this VRE";
private final static String TOOLTIP_REPLIES_DONE = "Post replies done during the last year";
private final static String TOOLTIP_REPLIES_DONE_VRE = "Post replies done during the last year in this VRE";
private final static String TOOLTIP_REPLIES_GOT = "Post replies got during the last year";
private final static String TOOLTIP_REPLIES_GOT_VRE = "Post replies got during the last year in this VRE";
/**
* improve profile hints
*/
@ -159,11 +154,6 @@ public class StatisticsPanel extends Composite {
*/
private long numberOfLikesGot;
/**
* Number of likes got
*/
private long numberOfCommentsGot;
/**
* Pagebus to listen for events (coming from the news feed portlet)
*/
@ -535,20 +525,7 @@ public class StatisticsPanel extends Composite {
TOOLTIP_LIKES_DONE_VRE + " (" + postsBean.getLikesMade() + ")",
ShowUserStatisticAction.LIKES_MADE_BY_USER,
information.getCurrentPageLanding());
if(isRoot || isProfilePage)
activityDone.setComments(
formattedNumbers(postsBean.getCommentsMade()),
TOOLTIP_REPLIES_DONE + " (" + postsBean.getCommentsMade() + ")",
ShowUserStatisticAction.COMMENTS_MADE_BY_USER,
information.getCurrentPageLanding());
else
activityDone.setComments(
formattedNumbers(postsBean.getCommentsMade()),
TOOLTIP_REPLIES_DONE_VRE +" (" + postsBean.getCommentsMade() + ")",
ShowUserStatisticAction.COMMENTS_MADE_BY_USER,
information.getCurrentPageLanding());
activityDoneWidgetContainer.appendToPanel(activityDone);
// updates comments and likes got
@ -572,21 +549,6 @@ public class StatisticsPanel extends Composite {
information.getCurrentPageLanding());
numberOfLikesGot = postsBean.getLikesReceived();
if(isRoot || isProfilePage)
activityGot.setComments(
formattedNumbers(postsBean.getCommentsReceived()),
TOOLTIP_REPLIES_GOT + " (" + postsBean.getCommentsReceived() + ")",
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
information.getCurrentPageLanding());
else
activityGot.setComments(
formattedNumbers(postsBean.getCommentsReceived()),
TOOLTIP_REPLIES_GOT_VRE + " (" + postsBean.getCommentsReceived() + ")",
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
information.getCurrentPageLanding());
numberOfCommentsGot = postsBean.getCommentsReceived();
activityGotWidgetContainer.appendToPanel(activityGot);
}
@ -811,83 +773,7 @@ public class StatisticsPanel extends Composite {
}
});
// increment comments got number
pageBusAdapter.PageBusSubscribe(PageBusEvents.commentsIncrement, null, null, null, null);
pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
@Override
public String getName() {
return PageBusEvents.commentsIncrement;
}
@Override
public void onPageBusSubscriptionCallback(PageBusEvent event) {
if(event.getSubject().equals(this.getName())){
GWT.log("Increment number of comments received");
numberOfCommentsGot ++;
if(isRoot)
activityGot.setComments(
formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT + " (" + numberOfCommentsGot + ")",
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else
activityGot.setComments(
formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT_VRE + " (" + numberOfCommentsGot + ")",
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
GWT.log("Number of comments got changed to " + numberOfCommentsGot);
}
}
});
// decrement comments got
pageBusAdapter.PageBusSubscribe(PageBusEvents.commentsDecrement, null, null, null, null);
pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
@Override
public String getName() {
return PageBusEvents.commentsDecrement;
}
@Override
public void onPageBusSubscriptionCallback(PageBusEvent event) {
if(event.getSubject().equals(this.getName())){
GWT.log("Decrement number of comments received");
// they can't be less than zero...
numberOfCommentsGot --;
numberOfCommentsGot = numberOfCommentsGot < 0 ? 0: numberOfCommentsGot;
if(isRoot)
activityGot.setComments(
formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT + " (" + numberOfCommentsGot + ")",
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else
activityGot.setComments(
formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT_VRE + " (" + numberOfCommentsGot + ")",
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
GWT.log("Number of comments got changed to " + numberOfCommentsGot);
}
}
});
GWT.log("Subscriptions ok");
} catch (PageBusAdapterException e) {
GWT.log(e.toString());

@ -25,9 +25,6 @@ public class ActivityWidget extends Composite {
@UiField
Button likesButton;
@UiField
Button commentsButton;
@UiField
Button postsButton;
@ -35,44 +32,10 @@ public class ActivityWidget extends Composite {
public ActivityWidget() {
initWidget(uiBinder.createAndBindUi(this));
// set styles
commentsButton.addStyleName("buttons-statistics-style");
likesButton.addStyleName("buttons-statistics-style");
postsButton.addStyleName("buttons-statistics-style");
}
/**
* Set comments information
* @param value
* @param tipIcon
* @param tipValue
* @param actionToTakeOnClick
* @param landingPage
*/
public void setComments(String value, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){
commentsButton.setText(value);
commentsButton.setTitle(tipValue);
if(busEvents != null && actionToTakeOnClick != null){
commentsButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick, landingPage));
}
});
}
// set to visible
commentsButton.setVisible(true);
}
/**
* Set likes information
* @param value

@ -15,8 +15,6 @@
visible="false"></b:Button>
<b:Button ui:field="likesButton" icon="THUMBS_UP_ALT" type="LINK"
visible="false"></b:Button>
<b:Button ui:field="commentsButton" icon="COMMENTS" type="LINK"
visible="false"></b:Button>
</g:HorizontalPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -4,9 +4,7 @@ import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
@ -22,7 +20,6 @@ import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.communitymanager.SiteManagerUtil;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portlet.user.userstatisticsportlet.client.UserStatisticsService;
import org.gcube.portlet.user.userstatisticsportlet.server.cache.UserInfrastructureQuotaStorageCache;
@ -288,10 +285,11 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
try {
long userId = userManager.getUserId(statisticsOfUsername);
List<Feed> userFeeds = store.getRecentFeedsByUserAndDate(statisticsOfUsername, oneYearAgo.getTimeInMillis());
List<Feed> userPosts = store.getRecentFeedsByUserAndDate(statisticsOfUsername, oneYearAgo.getTimeInMillis());
logger.debug("store.getRecentFeedsByUserAndDate");
List<Feed> recentLikedFeeds = store.getRecentLikedFeedsByUserAndDate(statisticsOfUsername, oneYearAgo.getTimeInMillis());
List<Comment> recentComments = store.getRecentCommentsByUserAndDate(statisticsOfUsername, oneYearAgo.getTimeInMillis());
logger.debug("store.getRecentLikedFeedsByUserAndDate");
// Evaluate the contexts to use
List<String> contexts = new ArrayList<String>();
if(isInfrastructure){
@ -305,12 +303,12 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
logger.info("Context(s) that are going to be used " + contexts);
long feedsMade = 0, likesGot = 0, commentsGot = 0, commentsMade = 0, likesMade = 0;
long postCreated = 0, likesGot = 0, commentsGot = 0, commentsMade = 0, likesMade = 0;
for (Feed feed : userFeeds) {
for (Feed feed : userPosts) {
if(contexts.contains(feed.getVreid())){
feedsMade ++;
postCreated ++;
commentsGot += Integer.parseInt(feed.getCommentsNo());
likesGot += Integer.parseInt(feed.getLikesNo());
}
@ -321,20 +319,7 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
likesMade ++;
}
Map<String, Feed> parentFeeds = new HashMap<String, Feed>();
for (Comment comment : recentComments) {
Feed parentFeed = null;
if(!parentFeeds.containsKey(comment.getFeedid())){
parentFeed = store.readFeed(comment.getFeedid());
parentFeeds.put(comment.getFeedid(), parentFeed);
}else
parentFeed = parentFeeds.get(comment.getFeedid());
if((contexts.contains(parentFeed.getVreid())))
commentsMade ++;
}
toReturn = new PostsStatsBean(feedsMade, likesGot, commentsGot, commentsMade, likesMade);
toReturn = new PostsStatsBean(postCreated, likesGot, commentsGot, commentsMade, likesMade);
}catch(Exception e){
logger.error("Error while retrieving user's statistics", e);

@ -15,8 +15,6 @@ public class PostsStatsBean implements Serializable{
private static final long serialVersionUID = 2043823499293477290L;
private long feedsNumber;
private long likesReceived;
private long commentsReceived;
private long commentsMade;
private long likesMade;
public PostsStatsBean(){
@ -35,8 +33,6 @@ public class PostsStatsBean implements Serializable{
super();
this.feedsNumber = feeds;
this.likesReceived = likesReceived;
this.commentsReceived = commentsReceived;
this.commentsMade = commentsMade;
this.likesMade = likesMade;
}
@ -56,22 +52,6 @@ public class PostsStatsBean implements Serializable{
this.likesReceived = likesReceived;
}
public long getCommentsReceived() {
return commentsReceived;
}
public void setCommentsReceived(long commentsReceived) {
this.commentsReceived = commentsReceived;
}
public long getCommentsMade() {
return commentsMade;
}
public void setCommentsMade(long commentsMade) {
this.commentsMade = commentsMade;
}
public long getLikesMade() {
return likesMade;
}
@ -82,10 +62,10 @@ public class PostsStatsBean implements Serializable{
@Override
public String toString() {
return "PostsStatsBean [feeds=" + feedsNumber + ", likesReceived="
+ likesReceived + ", commentsReceived=" + commentsReceived
+ ", commentsMade=" + commentsMade + ", likesMade=" + likesMade
+ "]";
return "PostsStatsBean [feedsNumber=" + feedsNumber + ", likesReceived=" + likesReceived + ", likesMade="
+ likesMade + "]";
}
}

Loading…
Cancel
Save