Skip to content

Commit 55f3740

Browse files
committed
add domain count for most domains
1 parent 16c9758 commit 55f3740

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

fetch-data.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,15 @@ fetch("https://raw-api.is-a.dev")
55
let totalRecords = 0;
66
const uniqueUsers = [...new Set(data.map((domain) => domain.owner.username))].length;
77
const averageDomainsPerUser = (totalDomains / uniqueUsers).toFixed(1);
8-
const userWithMostDomains = [
8+
let userWithMostDomains = [
99
...new Set(data.map((domain) => domain.owner.username)),
1010
].reduce((a, b) =>
1111
data.filter((domain) => domain.owner.username === a).length >=
1212
data.filter((domain) => domain.owner.username === b).length
1313
? a
1414
: b
1515
);
16-
const userWithMostRecords = [
17-
...new Set(data.map((domain) => domain.owner.username)),
18-
].reduce((a, b) =>
19-
data
20-
.filter((domain) => domain.owner.username === a)
21-
.reduce((acc, domain) => acc + Object.keys(domain.record).length, 0) >=
22-
data
23-
.filter((domain) => domain.owner.username === b)
24-
.reduce((acc, domain) => acc + Object.keys(domain.record).length, 0)
25-
? a
26-
: b
27-
);
16+
userWithMostDomains = `${userWithMostDomains} (${data.filter((domain) => domain.owner.username === userWithMostDomains).length})`;
2817

2918
let A = 0;
3019
let AAAA = 0;
@@ -99,7 +88,6 @@ fetch("https://raw-api.is-a.dev")
9988
document.getElementById("unique-users").innerText = uniqueUsers;
10089
document.getElementById("average-domains-per-user").innerText = averageDomainsPerUser;
10190
document.getElementById("user-with-most-domains").innerText = userWithMostDomains;
102-
document.getElementById("user-with-most-records").innerText = userWithMostRecords;
10391
document.getElementById("a-records").innerText = A;
10492
document.getElementById("aaaa-records").innerText = AAAA;
10593
document.getElementById("caa-records").innerText = CAA;

index.html

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ <h3 class="text-xl font-semibold my-4">Domain Statistics</h3>
2828
<li><span class="font-semibold">Unique Users</span>: <span id="unique-users">Loading...</span></li>
2929
<li><span class="font-semibold">Average amount of domains per user</span>: <span id="average-domains-per-user">Loading...</span></li>
3030
<li><span class="font-semibold">User with the most domains</span>: <span id="user-with-most-domains">Loading...</span></li>
31-
<li><span class="font-semibold">User with the most records</span>: <span id="user-with-most-records">Loading...</span></li>
3231
</ul>
3332

3433
<hr class="mt-4">

0 commit comments

Comments
 (0)