Skip to content

Commit 911f3df

Browse files
rmp22Saikrishna1504
authored andcommitted
[infra] updating downloads|team implementations
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
1 parent 5cdd62e commit 911f3df

2 files changed

Lines changed: 300 additions & 226 deletions

File tree

‎js/about.js‎

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,43 +120,58 @@ async function fetchDeviceMaintainers() {
120120
const cached = deviceMaintainersCache.get(cacheKey);
121121
const now = Date.now();
122122

123-
let data;
123+
let deviceData, maintainerData;
124124
if (cached && (now - cached.timestamp) < MAINTAINERS_CACHE_DURATION) {
125-
data = cached.data;
125+
deviceData = cached.deviceData;
126+
maintainerData = cached.maintainerData;
126127
} else {
127-
const response = await fetch('https://raw.githubusercontent.com/AxionAOSP/official_devices/refs/heads/main/dinfo.json', {
128-
cache: 'default'
129-
});
128+
const [downloadsRes, maintainersRes] = await Promise.all([
129+
fetch('https://raw.githubusercontent.com/AxionAOSP/official_devices/refs/heads/main/api/downloads.json', {
130+
cache: 'default'
131+
}),
132+
fetch('https://raw.githubusercontent.com/AxionAOSP/official_devices/refs/heads/main/api/maintainers.json', {
133+
cache: 'default'
134+
})
135+
]);
130136

131-
if (!response.ok) {
132-
throw new Error(`Failed to fetch device info: ${response.status}`);
137+
if (!downloadsRes.ok || !maintainersRes.ok) {
138+
throw new Error(`Failed to fetch device data`);
133139
}
134140

135-
data = await response.json();
141+
deviceData = await downloadsRes.json();
142+
maintainerData = await maintainersRes.json();
143+
136144
deviceMaintainersCache.set(cacheKey, {
137-
data: data,
145+
deviceData: deviceData,
146+
maintainerData: maintainerData,
138147
timestamp: now
139148
});
140149
}
141-
const devices = data.devices || [];
142150

151+
const maintainerIndex = new Map((maintainerData.maintainers || []).map(m => [m.id, m]));
152+
const devices = deviceData.devices || [];
143153
const maintainerMap = new Map();
144154

145155
devices.forEach(device => {
146-
const statusValue = device.status || 'Active';
156+
const statusValue = device.status || 'active';
147157
const statusLower = String(statusValue).toLowerCase();
148158
const isActive = statusLower === 'active';
149159

150-
if (device.github_username && device.maintainer && isActive) {
151-
const username = device.github_username;
152-
if (!maintainerMap.has(username)) {
153-
maintainerMap.set(username, {
154-
username: username,
155-
maintainer: device.maintainer,
156-
devices: []
157-
});
158-
}
159-
maintainerMap.get(username).devices.push(device.device_name || device.codename);
160+
if (isActive && device.maintainer_ids) {
161+
device.maintainer_ids.forEach(maintainerId => {
162+
const maintainer = maintainerIndex.get(maintainerId);
163+
if (maintainer && maintainer.github_username) {
164+
const username = maintainer.github_username;
165+
if (!maintainerMap.has(username)) {
166+
maintainerMap.set(username, {
167+
username: username,
168+
maintainer: maintainer.name || username,
169+
devices: []
170+
});
171+
}
172+
maintainerMap.get(username).devices.push(device.name || device.codename);
173+
}
174+
});
160175
}
161176
});
162177

0 commit comments

Comments
 (0)