Skip to content

Commit

Permalink
feat: A new request for getting application versions has been written (
Browse files Browse the repository at this point in the history
…#45)

Co-authored-by: Maxim Lyubimov <[email protected]>
  • Loading branch information
mlyubimov and mlyubimov authored Oct 31, 2023
1 parent 989097f commit b18f51d
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions frontend/src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,31 @@ async function fetchAppFap (params) {
}

async function fetchAppsVersions (uids) {
let query = ''
for (const uid of uids) {
query += 'uid=' + uid + '&'
const size = 100
const subUids = []

for (let i = 0; i < Math.ceil(uids.length / size); i++) {
subUids[i] = uids.slice((i * size), (i * size) + size)
}

const allVersions = []
for (const sliceUids of subUids) {
const res = await fetch(`${API_ENDPOINT}/1/application/versions`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
application_versions: sliceUids,
limit: size
})
}).then(res => res.json())

allVersions.push(...res)
}
const res = await fetch(`${API_ENDPOINT}/application/versions?${query}`).then(res => res.json())
const versions = res.map(version => camelCaseDeep(version))

const versions = allVersions.map(version => camelCaseDeep(version))
return versions
}

Expand Down

0 comments on commit b18f51d

Please sign in to comment.