Hi!
I have the following issue. I need to do a count of registered users per day in
my application.
I have the correct query, but I cannot display the results on screen.
I tried with different types of data, at the end I put a simple list of string
but sends me the following error, instead of information:
??? EntityModel objectAdapter oid: null
Could you recommend me another way that I can solve
this problem? or how could I get the count of some object by date?.
Thanks in advance.
Aida Davila
This is my code:
public List<String> FindNewUsersCountPerDay() {
System.out.println("Find");
List <User> MyUsers = this.findAllUsers();
List<String> lista = new ArrayList<String>();
Map<String, Long> countByDate = MyUsers.stream()
.collect(Collectors
.groupingBy(User::getCreationDate,
Collectors.counting())
);
Set<Map.Entry<String, Long>> set = countByDate.entrySet();
List<Map.Entry<String, Long>> userList = new ArrayList<>(set);
Iterator<Map.Entry<String, Long>> it = userList.iterator();
int index = 0;
while (it.hasNext()) {
Map.Entry<String, Long> entry = it.next();
String result = index + " " + entry.getKey() + " " + entry.getValue();
lista.add(result);
System.out.println("Entry from converted list : " + index + " 1:" +
entry.getKey() + " 2:" + entry.getValue());
index++;
}
System.out.println(countByDate);
return (lista);
}