add search names, fix working bug, lowercase all mails
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.champonthis</groupId>
|
<groupId>de.champonthis</groupId>
|
||||||
<artifactId>abi</artifactId>
|
<artifactId>abi</artifactId>
|
||||||
<version>0.1.0</version>
|
<version>0.2.0</version>
|
||||||
<name>abi</name>
|
<name>abi</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -48,9 +48,17 @@ public class ContactManager {
|
|||||||
if (StringUtils.isNoneEmpty(line) && !line.startsWith("#")
|
if (StringUtils.isNoneEmpty(line) && !line.startsWith("#")
|
||||||
&& contactRepository.findByName(line).isEmpty()) {
|
&& contactRepository.findByName(line).isEmpty()) {
|
||||||
Contact contact = new Contact();
|
Contact contact = new Contact();
|
||||||
contact.setName(line);
|
String[] nameParts = line.split(";");
|
||||||
|
contact.setName(nameParts[0]);
|
||||||
|
if (nameParts.length > 1) {
|
||||||
|
contact.setSearchName(nameParts[1]);
|
||||||
|
} else {
|
||||||
|
contact.setSearchName(nameParts[0]);
|
||||||
|
}
|
||||||
save(contact);
|
save(contact);
|
||||||
logger.info("Created contact: #" + contact.getId() + ": " + contact.getName());
|
logger.info("Created contact: #" + contact.getId() + ": " + contact.getName()
|
||||||
|
+ (contact.getName().equals(contact.getSearchName()) ? ""
|
||||||
|
: " | " + contact.getSearchName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,9 +88,28 @@ public class ContactManager {
|
|||||||
|
|
||||||
public Contact findByLevenshteinDistance(String name, int threshold) {
|
public Contact findByLevenshteinDistance(String name, int threshold) {
|
||||||
Contact result = null;
|
Contact result = null;
|
||||||
|
String[] nameParts = name.toLowerCase().split(" ");
|
||||||
|
if (nameParts.length < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
for (Contact contact : contactRepository.findAll()) {
|
for (Contact contact : contactRepository.findAll()) {
|
||||||
int distance = levenshteinDistance.apply(name.toLowerCase(), contact.getName().toLowerCase());
|
String[] contactParts = contact.getSearchName().toLowerCase().split(" ");
|
||||||
|
int matches = 0;
|
||||||
|
int index = 0;
|
||||||
|
if (contactParts.length < nameParts.length) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (String namePart : nameParts) {
|
||||||
|
for (int i = index; i < contactParts.length; i++) {
|
||||||
|
int distance = levenshteinDistance.apply(namePart, contactParts[i]);
|
||||||
if (distance <= threshold) {
|
if (distance <= threshold) {
|
||||||
|
matches++;
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (matches > 1) {
|
||||||
result = contact;
|
result = contact;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class ContactDataController {
|
|||||||
sendToken = true;
|
sendToken = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
contactData.setEmail(request.getEmail());
|
contactData.setEmail(request.getEmail().toLowerCase());
|
||||||
contactData.setPhone(request.getPhone());
|
contactData.setPhone(request.getPhone());
|
||||||
|
|
||||||
if (!contact.getId().equals(reportedBy.getId())
|
if (!contact.getId().equals(reportedBy.getId())
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ public class Contact {
|
|||||||
@Column(name = "id", nullable = false)
|
@Column(name = "id", nullable = false)
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private Long id;
|
private Long id;
|
||||||
|
@Column(nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
@JsonIgnore
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String searchName;
|
||||||
private String updatedName;
|
private String updatedName;
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private Commitment committed = Commitment.UNKNOWN;
|
private Commitment committed = Commitment.UNKNOWN;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
<form @submit.prevent="findSelf" class="d-flex flex-column gap-3 mb-3">
|
<form @submit.prevent="findSelf" class="d-flex flex-column gap-3 mb-3">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
Dein Name (wie auf dem Abi-T-Shirt)
|
Dein Name (wie im Abi-Buch)
|
||||||
</label>
|
</label>
|
||||||
<input type="text" x-model="yourName" required autocomplete="off"
|
<input type="text" x-model="yourName" required autocomplete="off"
|
||||||
class="form-control" autofocus />
|
class="form-control" autofocus />
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
<form @submit.prevent="continueStep1">
|
<form @submit.prevent="continueStep1">
|
||||||
<p>
|
<p>
|
||||||
Hallo <span x-text="altName || userName"></span>! Falls sich dein Name geändert hat,
|
Hallo <span x-text="altName || userName"></span>! Falls sich dein Name geändert hat,
|
||||||
kannst du ihn hier anpassen – oder einfach direkt weitermachen.
|
kannst du ihn hier anpassen - oder einfach direkt weitermachen.
|
||||||
</p>
|
</p>
|
||||||
<div id="altNameCheckboxDiv" class="form-check mt-3" x-show="userName" x-transition>
|
<div id="altNameCheckboxDiv" class="form-check mt-3" x-show="userName" x-transition>
|
||||||
<input type="checkbox" x-model="altNameChecked" class="form-check-input"
|
<input type="checkbox" x-model="altNameChecked" class="form-check-input"
|
||||||
@@ -184,7 +184,7 @@
|
|||||||
</h2>
|
</h2>
|
||||||
<form @submit.prevent="findKnownContact" class="mb-3">
|
<form @submit.prevent="findKnownContact" class="mb-3">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Name auf dem Abi-T-Shirt:</label>
|
<label class="form-label">Name (wie im Abi-Buch):</label>
|
||||||
<input type="text" x-model="knownContactName" required autocomplete="off"
|
<input type="text" x-model="knownContactName" required autocomplete="off"
|
||||||
class="form-control" autofocus />
|
class="form-control" autofocus />
|
||||||
</div>
|
</div>
|
||||||
@@ -314,7 +314,7 @@
|
|||||||
this.userName = resp.data.name;
|
this.userName = resp.data.name;
|
||||||
this.userToken = resp.data.token || null;
|
this.userToken = resp.data.token || null;
|
||||||
} else if (resp.status === 404) {
|
} else if (resp.status === 404) {
|
||||||
this.stepMsg = 'Sorry, wir konnten dich nicht finden. Schreib deinen Namen bitte genau so, wie er auf dem Abi-T-Shirt stand!';
|
this.stepMsg = 'Sorry, wir konnten dich nicht finden. Schreib deinen Namen bitte so, wie er im Abi-Buch stand!';
|
||||||
this.stepMsgType = 'warning';
|
this.stepMsgType = 'warning';
|
||||||
} else if (resp.status === 208) {
|
} else if (resp.status === 208) {
|
||||||
this.stepMsg = 'Du hast deine Daten schon eingetragen. Danke dir!';
|
this.stepMsg = 'Du hast deine Daten schon eingetragen. Danke dir!';
|
||||||
@@ -395,16 +395,16 @@
|
|||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
this.foundKnownContactName = resp.data.name.trim();
|
this.foundKnownContactName = resp.data.name.trim();
|
||||||
if (this.foundKnownContactName == this.yourName) {
|
if (this.foundKnownContactName == this.yourName) {
|
||||||
this.stepMsg = 'Das bist du selbst – deine Daten hast du ja schon eingetragen!';
|
this.stepMsg = 'Das bist du selbst - deine Daten hast du ja schon eingetragen!';
|
||||||
this.stepMsgType = 'warning';
|
this.stepMsgType = 'warning';
|
||||||
this.showKnownContactData = false;
|
this.showKnownContactData = false;
|
||||||
this.knownContactName = ''
|
this.knownContactName = ''
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
this.knownContactName = this.foundKnownContactName;
|
this.knownContactName = this.foundKnownContactName;
|
||||||
this.stepMsg = 'Super, trag bitte die Kontaktdaten ein!';
|
this.stepMsg = 'Super, trag bitte die Kontaktdaten ein!';
|
||||||
this.stepMsgType = 'success';
|
this.stepMsgType = 'success';
|
||||||
this.showKnownContactData = true;
|
this.showKnownContactData = true;
|
||||||
|
}
|
||||||
} else if (resp.status === 404) {
|
} else if (resp.status === 404) {
|
||||||
this.stepMsg = 'Diesen Namen gibt es leider nicht in unserer Liste.';
|
this.stepMsg = 'Diesen Namen gibt es leider nicht in unserer Liste.';
|
||||||
this.stepMsgType = 'warning';
|
this.stepMsgType = 'warning';
|
||||||
|
|||||||
Reference in New Issue
Block a user