use of com.pratilipi.data.type.PratilipiGoogleAnalyticsDoc in project pratilipi by Pratilipi.
the class PratilipiDataUtil method updatePratilipiStats.
public static void updatePratilipiStats(Long pratilipiId) throws UnexpectedServerException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
Pratilipi pratilipi = dataAccessor.getPratilipi(pratilipiId);
PratilipiGoogleAnalyticsDoc gaDoc = docAccessor.getPratilipiGoogleAnalyticsDoc(pratilipiId);
Page pratilipiPage = dataAccessor.getPage(PageType.PRATILIPI, pratilipiId);
long readCountOffset = 0L;
for (int month = 1; month <= 12; month++) for (int day = 1; day <= 31; day++) readCountOffset += gaDoc.getPageViews(2015, month, day);
for (int month = 1; month <= 4; month++) for (int day = 1; day <= 31; day++) readCountOffset += gaDoc.getPageViews(2016, month, day);
long readCount = gaDoc.getTotalReadPageViews();
long fbLikeShareCount = FacebookApi.getUrlShareCount("http://" + Website.ALL_LANGUAGE.getHostName() + pratilipiPage.getUri());
if (pratilipi.getReadCountOffset() == readCountOffset && pratilipi.getReadCount() == readCount && pratilipi.getFbLikeShareCount() == fbLikeShareCount)
return;
updatePratilipiStats(pratilipiId, readCountOffset, readCount, null, fbLikeShareCount);
}
use of com.pratilipi.data.type.PratilipiGoogleAnalyticsDoc in project pratilipi by Pratilipi.
the class PratilipiDocUtil method updatePratilipiGoogleAnalyticsPageViews.
public static void updatePratilipiGoogleAnalyticsPageViews(Long pratilipiId, int year, int month, int day, int pageViews, int readPageViews) throws UnexpectedServerException {
DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
PratilipiGoogleAnalyticsDoc gaDoc = docAccessor.getPratilipiGoogleAnalyticsDoc(pratilipiId);
gaDoc.setPageViews(year, month, day, pageViews);
gaDoc.setReadPageViews(year, month, day, readPageViews);
docAccessor.save(pratilipiId, gaDoc);
}
Aggregations