Skip to content

Commit

Permalink
Merge pull request #266 from nicolas-f/fixparse
Browse files Browse the repository at this point in the history
Ignore uploads with wrong calibration gain
  • Loading branch information
nicolas-f authored Apr 9, 2018
2 parents 73f6b82 + 2b74b51 commit 93cef2c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def static Integer processFile(Connection connection, File zipFile, boolean stor
Integer.valueOf(meta.getProperty("pleasantness")) <= 100)) {
throw new InvalidParameterException("Wrong pleasantness \"" + meta.getProperty("pleasantness") + "\"")
}
Double gain = Double.valueOf(meta.getProperty("gain_calibration", "0").replace(",", "."))
if (!(gain > -150 && gain < 150)) {
throw new InvalidParameterException("Wrong gain \"" + gain + "\"")
}
// Maximum 15 minutes of time ahead of server time
if(Long.valueOf(meta.getProperty("record_utc")) > System.currentTimeMillis() + (15*60*1000)) {
throw new InvalidParameterException("Wrong time, superior than server time \"" + epochToRFCTime(Long.valueOf(meta.getProperty("record_utc"))) + "\"")
Expand Down Expand Up @@ -163,7 +167,7 @@ def static Integer processFile(Connection connection, File zipFile, boolean stor
device_manufacturer: meta.get("device_manufacturer"),
noise_level : Double.valueOf(meta.getProperty("leq_mean").replace(",", ".")),
time_length : meta.get("time_length") as int,
gain_calibration : Double.valueOf(meta.getProperty("gain_calibration", "0").replace(",", ".")),
gain_calibration : gain,
noiseparty_id : idParty]
def recordId = sql.executeInsert("INSERT INTO noisecapture_track(track_uuid, pk_user, version_number, record_utc," +
" pleasantness, device_product, device_model, device_manufacturer, noise_level, time_length, gain_calibration, pk_party) VALUES (" +
Expand Down

0 comments on commit 93cef2c

Please sign in to comment.