+ /**
+ * Remove duplicates in {@code List} of {@code UserAction} objects. We need to clean this up for user actions
+ * that appear multiple times.
+ * TODO: This static method is probably just for temporary and we could get rid of this after we clean up
+ * TODO: the pipeline
+ *
+ * @param listUserAction A {@link List} of {@code UserAction}.
+ *
+ */
+ public static List<UserAction> removeDuplicates(List<UserAction> listUserAction) {
+
+ // Iterate and check for duplicates (check timestamps)
+ Set<Long> epochSecondSet = new HashSet<>();
+ // Create a target list for cleaned up list
+ List<UserAction> listUserActionClean = new ArrayList<>();
+ for(UserAction userAction : listUserAction) {
+ // Don't insert if any duplicate is found
+ if(!epochSecondSet.contains(userAction.getTimestamp().getEpochSecond())) {
+ listUserActionClean.add(userAction);
+ epochSecondSet.add(userAction.getTimestamp().getEpochSecond());
+ }
+ }
+ return listUserActionClean;
+ }
+