Skip to content

Commit 328c894

Browse files
authored
Remove Lodash (#1246)
1 parent 299e96d commit 328c894

File tree

15 files changed

+51
-62
lines changed

15 files changed

+51
-62
lines changed

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"highlight.js": "^10.4.1",
1717
"jquery": "^3.5.0",
1818
"laravel-mix": "^6.0.13",
19-
"lodash": "^4.17.19",
2019
"md5": "^2.2.1",
2120
"moment": "^2.29.4",
2221
"moment-timezone": "^0.5.35",

public/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"/app.js": "/app.js?id=766b568d1924aa83b2a1f279d2c5ab9e",
2+
"/app.js": "/app.js?id=11fdcdd352319325cdc6732793bdae1d",
33
"/app-dark.css": "/app-dark.css?id=15c72df05e2b1147fa3e4b0670cfb435",
44
"/app.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5",
55
"/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f",

resources/js/base.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,25 @@ export default {
5252
readableTimestamp(timestamp) {
5353
return this.formatDate(timestamp).format('YYYY-MM-DD HH:mm:ss');
5454
},
55+
56+
/**
57+
* Uppercase the first character of the string.
58+
*/
59+
upperFirst(string) {
60+
return string.charAt(0).toUpperCase() + string.slice(1);
61+
},
62+
63+
/**
64+
* Group array entries by a given key.
65+
*/
66+
groupBy(array, key) {
67+
return array.reduce((grouped, entry) => ({
68+
...grouped,
69+
[entry[key]]: [
70+
...(grouped[entry[key]] || []),
71+
entry,
72+
],
73+
}), {});
74+
},
5575
},
5676
};

resources/js/components/LineChart.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
display: true
3939
},
4040
beforeBuildTicks: function (scale) {
41-
var max = _.max(scale.chart.data.datasets[0].data);
41+
var max = scale.chart.data.datasets[0].data.reduce((max, value) => value > max ? value : max)
4242
4343
scale.max = parseFloat(max) + parseFloat(max * 0.25);
4444
},

resources/js/components/Stacktrace.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script type="text/ecmascript-6">
2-
import _take from "lodash/take"
3-
42
export default {
53
props: ['trace'],
64
@@ -16,7 +14,7 @@
1614
1715
computed: {
1816
lines() {
19-
return this.showAll ? _take(this.trace, 1000) : _take(this.trace, this.minimumLines);
17+
return this.trace.slice(0, this.showAll ? 1000 : this.minimumLines);
2018
}
2119
}
2220
}

resources/js/screens/batches/index.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
return;
6161
}
6262
63-
64-
if (!this.$root.autoLoadsNewEntries && refreshing && this.batches.length && _.first(response.data.batches).id !== _.first(this.batches).id) {
63+
if (!this.$root.autoLoadsNewEntries && refreshing && this.batches.length && response.data.batches[0]?.id !== this.batches[0]?.id) {
6564
this.hasNewEntries = true;
6665
} else {
6766
this.batches = response.data.batches;
@@ -111,10 +110,10 @@
111110
* Load the batches for the next page.
112111
*/
113112
next() {
114-
this.previousFirstId = _.first(this.batches).id + '0';
113+
this.previousFirstId = this.batches[0]?.id + '0';
115114
116115
this.loadBatches(
117-
_.last(this.batches).id
116+
this.batches.slice(-1)[0]?.id
118117
);
119118
120119
this.page += 1;

resources/js/screens/dashboard.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script type="text/ecmascript-6">
2-
import _ from 'lodash';
32
import moment from 'moment';
43
54
export default {
@@ -68,9 +67,9 @@
6867
.then(response => {
6968
this.stats = response.data;
7069
71-
if (_.values(response.data.wait)[0]) {
72-
this.stats.max_wait_time = _.values(response.data.wait)[0];
73-
this.stats.max_wait_queue = _.keys(response.data.wait)[0].split(':')[1];
70+
if (Object.values(response.data.wait)[0]) {
71+
this.stats.max_wait_time = Object.values(response.data.wait)[0];
72+
this.stats.max_wait_queue = Object.keys(response.data.wait)[0].split(':')[1];
7473
}
7574
});
7675
},
@@ -120,15 +119,15 @@
120119
* Count processes for the given supervisor.
121120
*/
122121
countProcesses(processes) {
123-
return _.chain(processes).values().sum().value().toLocaleString()
122+
return Object.values(processes).reduce((total, value) => total + value, 0).toLocaleString();
124123
},
125124
126125
127126
/**
128127
* Format the Supervisor display name.
129128
*/
130129
superVisorDisplayName(supervisor, worker) {
131-
return _.replace(supervisor, worker + ':', '');
130+
return supervisor.replace(worker + ':', '');
132131
},
133132
134133

resources/js/screens/failedJobs/index.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@
7676
return;
7777
}
7878
79-
80-
if (!this.$root.autoLoadsNewEntries && refreshing && this.jobs.length && _.first(response.data.jobs).id !== _.first(this.jobs).id) {
79+
if (!this.$root.autoLoadsNewEntries && refreshing && this.jobs.length && response.data.jobs[0]?.id !== this.jobs[0]?.id) {
8180
this.hasNewEntries = true;
8281
} else {
8382
this.jobs = response.data.jobs;
@@ -112,10 +111,10 @@
112111
this.$http.post(Horizon.basePath + '/api/jobs/retry/' + id)
113112
.then((response) => {
114113
setTimeout(() => {
115-
this.retryingJobs = _.reject(this.retryingJobs, job => job == id);
114+
this.retryingJobs = this.retryingJobs.filter(job => job != id);
116115
}, 5000);
117116
}).catch(error => {
118-
this.retryingJobs = _.reject(this.retryingJobs, job => job == id);
117+
this.retryingJobs = this.retryingJobs.filter(job => job != id);
119118
});
120119
},
121120
@@ -124,15 +123,15 @@
124123
* Determine if the given job is currently retrying.
125124
*/
126125
isRetrying(id) {
127-
return _.includes(this.retryingJobs, id);
126+
return this.retryingJobs.includes(id);
128127
},
129128
130129
131130
/**
132131
* Determine if the given job has completed.
133132
*/
134133
hasCompleted(job) {
135-
return _.find(job.retried_by, retry => retry.status == 'completed');
134+
return job.retried_by.find(retry => retry.status === 'completed');
136135
},
137136
138137
@@ -157,7 +156,7 @@
157156
retriedJobTooltip(job) {
158157
let lastRetry = job.retried_by[job.retried_by.length - 1];
159158
160-
return `Total retries: ${job.retried_by.length}, Last retry status: ${_.upperFirst(lastRetry.status)}`;
159+
return `Total retries: ${job.retried_by.length}, Last retry status: ${this.upperFirst(lastRetry.status)}`;
161160
},
162161
163162
/**

0 commit comments

Comments
 (0)