event.setCategory(Event.CATEGORY_PROFILE);
Date from = previousProfile.getRulesUpdatedAt();
- // strictly greater than previous date
- // This hack must be done because date precision is millisecond in db/es and date format is select only
- from = DateUtils.addSeconds(from, 1);
-
String data = KeyValueFormat.format(ImmutableSortedMap.of(
"key", profile.getKey(),
- "from", UtcDateUtils.formatDateTime(from),
- "to", UtcDateUtils.formatDateTime(profile.getRulesUpdatedAt())));
+ "from", UtcDateUtils.formatDateTime(fixDate(from)),
+ "to", UtcDateUtils.formatDateTime(fixDate(profile.getRulesUpdatedAt()))));
event.setData(data);
persistenceManager.saveEvent(context.getResource(), event);
}
+ /**
+ * This hack must be done because date precision is millisecond in db/es and date format is select only
+ */
+ private Date fixDate(Date date) {
+ return DateUtils.addSeconds(date, 1);
+ }
+
private void markAsRemoved(DecoratorContext context, QProfile profile) {
context.createEvent(String.format("Stop using %s", profileLabel(profile)), null, Event.CATEGORY_PROFILE, null);
}
Event event = (Event) item;
return event.getCategory().equals(Event.CATEGORY_PROFILE) &&
"Changes in 'Java One' (Java)".equals(event.getName()) &&
- // "from" is one second more !
- "from=2014-01-15T12:00:01+0000;key=J1;to=2014-02-20T12:00:00+0000".equals(event.getData());
+ // "from" and "to" must have one second more because of lack of ms precision
+ "from=2014-01-15T12:00:01+0000;key=J1;to=2014-02-20T12:00:01+0000".equals(event.getData());
}
}));
}