Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Jun 9, 2022
1 parent c103ea0 commit b745c86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
12 changes: 4 additions & 8 deletions helpers/licencesDB/getNextLicenceNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@ const getCategoryNDigitsLicenceNumber = (database, licenceCategory, digits, dist
database.function("userFn_digits", (licenceNumber) => {
return licenceNumber.slice(Math.max(0, licenceNumber.lastIndexOf("-") + 1));
});
let licenceNumber;
if (distinctDigits) {
licenceNumber = database.prepare("select licenceNumber from Licences" +
const licenceNumber = distinctDigits
? database.prepare("select licenceNumber from Licences" +
" order by userFn_digits(licenceNumber) desc")
.pluck()
.get();
}
else {
licenceNumber = database.prepare("select licenceNumber from Licences" +
.get()
: database.prepare("select licenceNumber from Licences" +
" where length(licenceNumber) = ?" +
" and userFn_matchesFormat(licenceNumber) = 1" +
" order by licenceNumber desc")
.pluck()
.get(licenceNumberLength);
}
if (!licenceNumber) {
return categorySlug + "-" + "1".padStart(digits, "0");
}
Expand Down
15 changes: 4 additions & 11 deletions helpers/licencesDB/getNextLicenceNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,17 @@ const getCategoryNDigitsLicenceNumber = (database: sqlite.Database, licenceCateg
return licenceNumber.slice(Math.max(0, licenceNumber.lastIndexOf("-") + 1));
});

let licenceNumber: string;

if (distinctDigits) {

licenceNumber = database.prepare("select licenceNumber from Licences" +
const licenceNumber: string = distinctDigits
? database.prepare("select licenceNumber from Licences" +
" order by userFn_digits(licenceNumber) desc")
.pluck()
.get();

} else {

licenceNumber = database.prepare("select licenceNumber from Licences" +
.get()
: database.prepare("select licenceNumber from Licences" +
" where length(licenceNumber) = ?" +
" and userFn_matchesFormat(licenceNumber) = 1" +
" order by licenceNumber desc")
.pluck()
.get(licenceNumberLength);
}

if (!licenceNumber) {
return categorySlug + "-" + "1".padStart(digits, "0");
Expand Down

0 comments on commit b745c86

Please sign in to comment.