static AverageStat localActivityTimeStat = StatsServlet
.createAverageStat("local_activity_total_time");
@Override
public SearchResponse localActivity() {
QuotaService qs = QuotaServiceFactory.getQuotaService();
long start = qs.getCpuTimeInMegaCycles();
long t = System.currentTimeMillis();
SearchResponse response = new SearchResponse();
try {
List<SearchResult> has = new ArrayList<SearchResult>();
List<SearchResult> need = new ArrayList<SearchResult>();
long temp = System.currentTimeMillis();
Participant pi = pm.findParticipantByEmail(getUserId());
LOG.info("For Local Activity findParticipantByEmail(getUserId()) "
+ (System.currentTimeMillis() - temp));
if (pi == null) {
return response;
}
Location location = new Location(pi.getLocation().getLat(), pi
.getLocation().getLon(), pi.getLoc().getLocationString(),
pi.getLoc().getActiveRadius());
temp = System.currentTimeMillis();
List<Participant> participants = pm
.searchParticipantsByLocation(location);
LOG.info("For Local Activity searchParticipantsByLocation(location) "
+ (System.currentTimeMillis() - temp));
for (Participant p : participants) {
double distance = GeocellUtils.distance(pi.getLocation(), p
.getLocation());
has.add(new SearchResult(ValueObjectGenerator.create(p), true,
p.getHasSubjects(), distance));
need.add(new SearchResult(ValueObjectGenerator.create(p),
false, p.getNeedSubjects(), distance));
}
temp = System.currentTimeMillis();
List<Opportunity> opportunities = om.allOpportunites(location);
LOG.info("For Local Activity allOpportunites(location) "
+ (System.currentTimeMillis() - temp));
for (Opportunity o : opportunities) {
need.add(new SearchResult(ValueObjectGenerator.create(o), o
.getSubjects(), GeocellUtils.distance(pi.getLocation(),
o.getLocation())));
}
response.setHas(has);
response.setNeed(need);
response = filterMe(pi, response);
long end = qs.getCpuTimeInMegaCycles();
double cpuSeconds = qs.convertMegacyclesToCpuSeconds(end - start);
LOG.info("Local Activity CPU Usage : " + cpuSeconds);
return response;
} catch (MentorException e) {
e.printStackTrace();
} finally {