Created
January 11, 2015 09:51
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
// 指定されたユーザの24時間分のデータを取得する | |
// 対応Routes: | |
// GET /fetchFromHours controllers.Application.fetchFromHoursGet(email:String ?="foo@bar.com") | |
// テスト用curl: | |
// curl --header "Content-type: application/json" --request GET http://localhost:9000/fetchFromHours | |
@Security.Authenticated(Secured.class) | |
public static Result fetchFromHoursGet(String inEmail) { | |
User owner = User.findByEmail(inEmail); | |
System.out.println(inEmail); | |
Calendar calFrom = Calendar.getInstance(); | |
calFrom.setTime(new Date()); | |
calFrom.add(Calendar.HOUR_OF_DAY, -24); | |
calFrom.set(Calendar.MILLISECOND, 0); | |
Integer hours = 24; | |
List<SensorData> sds = SensorData.findByUserSinceDateForHours(owner, calFrom, hours); | |
if (sds == null || sds.size() == 0) { | |
return badRequest("no data found"); | |
} | |
List<SensorDataRest> sdr = new ArrayList<SensorDataRest>(); | |
for (SensorData sd : sds) { | |
sdr.add(new SensorDataRest(sd)); | |
} | |
return ok(Json.toJson(sdr)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment