-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added manager field to user event reporting for line managers to see …
…reports
- Loading branch information
Showing
5 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/redhat/sso/ninja/user/CachedUserService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.redhat.sso.ninja.user; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.naming.NamingException; | ||
|
||
public class CachedUserService extends UserService{ | ||
private Map<String,List<User>> cache=new HashMap<>(); | ||
int cachedCount=0; | ||
int notCachedCount=0; | ||
|
||
@Override | ||
public List<User> search(String field, String value) throws NamingException{ | ||
boolean cached=true; | ||
if (!cache.containsKey(field+value)){ | ||
notCachedCount+=1; | ||
cache.put(field+value, super.search(field, value)); | ||
} | ||
if (cached) | ||
cachedCount+=1;//System.out.println("returned cached user: "+cache.get(field+value).get(0).getUid()); | ||
return cache.get(field+value); | ||
} | ||
|
||
public void printCacheStats(){ | ||
System.out.println("cached ["+cachedCount+"], not cached ["+notCachedCount+"]"); | ||
cachedCount=0; | ||
notCachedCount=0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/test/java/com/redhat/sso/ninja/controllers/EventsControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.redhat.sso.ninja.controllers; | ||
|
||
import org.junit.Test; | ||
|
||
import com.redhat.sso.ninja.utils.MapBuilder; | ||
|
||
public class EventsControllerTest{ | ||
|
||
@Test | ||
public void testGetEventsV2_30DaysOld() throws Exception{ | ||
|
||
long s=System.currentTimeMillis(); | ||
new EventsController().getEventsV2(new MapBuilder<String,String>().put("daysOld","30").build()); | ||
// System.out.println( | ||
//new ExportController().exportEvents(null, "csv") | ||
// ); | ||
System.out.println("took "+(System.currentTimeMillis()-s+"ms")); | ||
} | ||
} |