use of com.pratilipi.data.client.AuthorByReadCountData in project pratilipi by Pratilipi.
the class AuthorDataUtil method createAuthorByReadCountDataList.
public static List<AuthorByReadCountData> createAuthorByReadCountDataList(List<AuthorByReadCount> authorByReadCountList) {
List<AuthorByReadCountData> authorByReadCountDataList = new ArrayList<>(authorByReadCountList.size());
for (AuthorByReadCount authorByReadCount : authorByReadCountList) {
logger.log(Level.INFO, "Author Name : " + authorByReadCount.getName());
AuthorByReadCountData data = createAuthorByReadCountData(authorByReadCount);
authorByReadCountDataList.add(data);
}
return authorByReadCountDataList;
}
use of com.pratilipi.data.client.AuthorByReadCountData in project pratilipi by Pratilipi.
the class AuthorDataUtil method createAuthorByReadCountData.
/**
* Developer : Rahul Ranjan
* Function : Following functions are used for Author leaders board.
*/
public static AuthorByReadCountData createAuthorByReadCountData(AuthorByReadCount authorByReadCount) {
AuthorByReadCountData authorByReadCountData = new AuthorByReadCountData();
authorByReadCountData.setId(authorByReadCount.getId());
authorByReadCountData.setAuthorId(authorByReadCount.getAuthorId());
authorByReadCountData.setName(authorByReadCount.getName());
authorByReadCountData.setUserId(authorByReadCount.getUserId());
authorByReadCountData.setImageUrl(authorByReadCount.getCoverImageUrl());
authorByReadCountData.setPageUrl(authorByReadCount.getProfilePageUrl());
authorByReadCountData.setReadCount(authorByReadCount.getReadCount());
return authorByReadCountData;
}
use of com.pratilipi.data.client.AuthorByReadCountData in project pratilipi by Pratilipi.
the class AuthorDataUtil method getAuthorListByReadCount.
public static DataListCursorTuple<AuthorByReadCountData> getAuthorListByReadCount(Language language, Integer resultCount, String cursor) {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
AppProperty appProperty = dataAccessor.getAppProperty(AppProperty.TOP_AUTHORS_DATE);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
String dateString;
if (appProperty == null) {
// IF AppProperty is not present return day before yesterday's date.
// Same is present in AppPropertyUtil.getTopAuthorLoadDate function, line 52
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -2);
dateString = dateFormat.format(cal.getTime());
} else {
logger.log(Level.INFO, "AppProperty value : " + appProperty.getValue());
dateString = appProperty.getValue();
}
try {
Date date = dateFormat.parse(dateString);
logger.log(Level.INFO, "Filter : " + date);
DataListCursorTuple<AuthorByReadCount> cursorTuple = dataAccessor.getAuthorsByReadCount(date, language, resultCount, cursor);
List<AuthorByReadCountData> authorsData = createAuthorByReadCountDataList(cursorTuple.getDataList());
logger.log(Level.INFO, "Number of authors returned : " + authorsData.size());
return new DataListCursorTuple<>(authorsData, cursorTuple.getCursor(), cursorTuple.getNumberFound());
} catch (ParseException e) {
e.printStackTrace();
logger.log(Level.SEVERE, "Error while parsing date.");
return null;
}
}
use of com.pratilipi.data.client.AuthorByReadCountData in project pratilipi by Pratilipi.
the class AuthorListByReadCountApi method get.
@Get
public GetResponse get(GetRequest request) throws UnexpectedServerException {
DataListCursorTuple<AuthorByReadCountData> dataListCursorTuple = AuthorDataUtil.getAuthorListByReadCount(request.getLanguage(), request.getResultCount(), request.getCursor());
if (dataListCursorTuple == null) {
Logger.getLogger(AuthorListByReadCountApi.class.getSimpleName()).log(Level.INFO, "DB returned null cursor tuple");
throw new UnexpectedServerException();
}
Date date = AppPropertyUtil.getTopAuthorLoadDate();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Logger.getLogger(AuthorListByReadCountApi.class.getSimpleName()).log(Level.INFO, "Date : " + dateFormat.format(date));
return new GetResponse(dataListCursorTuple.getDataList(), dateFormat.format(date), dataListCursorTuple.getCursor());
}
Aggregations