refactor: delete duplicated code
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
1bd4b02a62
commit
44e95a00c3
|
@ -55,8 +55,8 @@ module.exports = Self => {
|
|||
SELECT e.*
|
||||
FROM vn.zoneExclusion e
|
||||
LEFT JOIN vn.zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
|
||||
WHERE zoneFk = ?
|
||||
AND dated BETWEEN ? AND ?
|
||||
WHERE e.zoneFk = ?
|
||||
AND e.dated BETWEEN ? AND ?
|
||||
AND eg.zoneExclusionFk IS NULL;`;
|
||||
const exclusions = await Self.rawSql(query, [zoneFk, started, ended], myOptions);
|
||||
|
||||
|
@ -64,8 +64,8 @@ module.exports = Self => {
|
|||
SELECT eg.*, e.zoneFk, e.dated, e.created, e.userFk
|
||||
FROM vn.zoneExclusion e
|
||||
LEFT JOIN vn.zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id
|
||||
WHERE zoneFk = ?
|
||||
AND dated BETWEEN ? AND ?
|
||||
WHERE e.zoneFk = ?
|
||||
AND e.dated BETWEEN ? AND ?
|
||||
AND eg.zoneExclusionFk IS NOT NULL;`;
|
||||
const geoExclusions = await Self.rawSql(query, [zoneFk, started, ended], myOptions);
|
||||
|
||||
|
|
|
@ -175,9 +175,7 @@ class Controller extends Section {
|
|||
return this.exclusionGeoCreate();
|
||||
}
|
||||
case 'delete':
|
||||
if (type == 'all')
|
||||
return this.exclusionDelete(this.exclusions);
|
||||
return this.exclusionGeoDelete(this.exclusionGeos);
|
||||
return this.exclusionDelete(this.excludeSelected);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,41 +234,10 @@ class Controller extends Section {
|
|||
return req.then(() => this.refresh());
|
||||
}
|
||||
|
||||
exclusionDelete(exclusions) {
|
||||
const reqs = [];
|
||||
|
||||
for (let exclusion of exclusions) {
|
||||
if (!exclusion.id) continue;
|
||||
const path = `${this.exclusionsPath}/${exclusion.id}`;
|
||||
reqs.push(this.$http.delete(path));
|
||||
}
|
||||
|
||||
this.$q.all(reqs)
|
||||
.then(() => {
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
exclusionGeoDelete(exclusionsGeo) {
|
||||
const reqs = [];
|
||||
|
||||
for (let exclusionGeo of exclusionsGeo) {
|
||||
if (!exclusionGeo.id) continue;
|
||||
const path = `${this.exclusionsPath}/${exclusionGeo.zoneExclusionFk}`;
|
||||
reqs.push(this.$http.delete(path));
|
||||
}
|
||||
|
||||
this.$q.all(reqs)
|
||||
.then(() => {
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
resetExclusions() {
|
||||
this.excludeSelected = null;
|
||||
this.isNew = null;
|
||||
this.exclusions = [];
|
||||
this.exclusionGeos = [];
|
||||
exclusionDelete(exclusion) {
|
||||
const path = `${this.exclusionsPath}/${exclusion.id}`;
|
||||
return this.$http.delete(path)
|
||||
.then(() => this.refresh());
|
||||
}
|
||||
|
||||
set excludeSearch(value) {
|
||||
|
|
Loading…
Reference in New Issue