Duplicate Detection Example

In Diffgram

Search Detect Any Duplicate

Video Example

Example of detecting duplicates

let duplicate_instances = []
let found_label_file_ids = []

for (let instance of diffgram.instance_list){
  	if (instance.soft_delete == true) {continue}
	if (!found_label_file_ids.includes(instance.label_file_id)) {
       found_label_file_ids.push(instance.label_file_id)   	
    } else {
    	duplicate_instances.push(instance)
    }
}

if (duplicate_instances.length > 0) {
    let instance = duplicate_instances[0]
    let label = diffgram.label_list.find(
      x=> {return x.id == instance.label_file_id}).label
    let message = "Duplicate: " + label.name
	diffgram.show_snackbar(message)
} else {
  let message = "No duplicates found."
  diffgram.show_snackbar(message)
}

In Watcher

// click "Watch"
create_instance: function (data){
  let duplicate_instances = []
  let found_label_file_ids = []

  for (let instance of diffgram.instance_list){
      if (instance.soft_delete == true) {continue}
      if (!found_label_file_ids.includes(instance.label_file_id)) {
         found_label_file_ids.push(instance.label_file_id)   	
      } else {
          duplicate_instances.push(instance)
      }
  }

  if (duplicate_instances.length > 0) {
      let instance = duplicate_instances[0]
      let label = diffgram.label_list.find(
        x=> {return x.id == instance.label_file_id}).label
      let message = "Duplicate: " + label.name
      diffgram.show_snackbar(message)
  } else {
    let message = "Example No duplicates found."
    diffgram.show_snackbar(message)
  }
}