Search in sources :

Example 1 with PratilipiGoogleAnalyticsDoc

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);
}
Also used : DataAccessor(com.pratilipi.data.DataAccessor) DocAccessor(com.pratilipi.data.DocAccessor) PratilipiGoogleAnalyticsDoc(com.pratilipi.data.type.PratilipiGoogleAnalyticsDoc) Page(com.pratilipi.data.type.Page) Pratilipi(com.pratilipi.data.type.Pratilipi) UserPratilipi(com.pratilipi.data.type.UserPratilipi)

Example 2 with PratilipiGoogleAnalyticsDoc

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);
}
Also used : DocAccessor(com.pratilipi.data.DocAccessor) PratilipiGoogleAnalyticsDoc(com.pratilipi.data.type.PratilipiGoogleAnalyticsDoc)

Aggregations

DocAccessor (com.pratilipi.data.DocAccessor)2 PratilipiGoogleAnalyticsDoc (com.pratilipi.data.type.PratilipiGoogleAnalyticsDoc)2 DataAccessor (com.pratilipi.data.DataAccessor)1 Page (com.pratilipi.data.type.Page)1 Pratilipi (com.pratilipi.data.type.Pratilipi)1 UserPratilipi (com.pratilipi.data.type.UserPratilipi)1