use of com.pratilipi.data.type.gae.UserEntity in project pratilipi by Pratilipi.
the class UserProcessApi method get.
@Get
public GenericResponse get(GenericRequest request) {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
// Fetching AppProperty
AppProperty appProperty = dataAccessor.getAppProperty(appPropertyId);
if (appProperty == null) {
appProperty = dataAccessor.newAppProperty(appPropertyId);
appProperty.setValue(new Date(0));
}
List<Key<UserEntity>> keyList = ObjectifyService.ofy().load().type(UserEntity.class).filter("SIGN_UP_DATE >", appProperty.getValue()).order("SIGN_UP_DATE").limit(10000).keys().list();
// Creating task for each user.
List<Task> taskList = new ArrayList<>(keyList.size());
for (Key<UserEntity> key : keyList) {
Task task = TaskQueueFactory.newTask().setUrl("/user/process").addParam("userId", key.getId() + "").addParam("validateData", "true");
taskList.add(task);
}
TaskQueueFactory.getUserOfflineTaskQueue().addAll(taskList);
logger.log(Level.INFO, "Added " + taskList.size() + " tasks.");
// Updating AppProperty.
if (taskList.size() > 0) {
appProperty.setValue(dataAccessor.getUser(keyList.get(keyList.size() - 1).getId()).getSignUpDate());
dataAccessor.createOrUpdateAppProperty(appProperty);
}
return new GenericResponse();
}
Aggregations