fix totalCount

This commit is contained in:
Namrata Jha
2021-12-22 21:39:57 +00:00
committed by GitHub
parent 1a7a0291b8
commit 8283350471
2 changed files with 11 additions and 2 deletions
+3 -1
View File
@@ -32,7 +32,7 @@ let totalCount = 0;
function getVersionIds(owner, repo, packageName, numVersions, cursor, token) { function getVersionIds(owner, repo, packageName, numVersions, cursor, token) {
return version_1.getOldestVersions(owner, repo, packageName, numVersions, cursor, token).pipe(operators_1.expand(value => value.paginate return version_1.getOldestVersions(owner, repo, packageName, numVersions, cursor, token).pipe(operators_1.expand(value => value.paginate
? version_1.getOldestVersions(owner, repo, packageName, numVersions, value.cursor, token) ? version_1.getOldestVersions(owner, repo, packageName, numVersions, value.cursor, token)
: rxjs_1.EMPTY), operators_1.tap(value => (totalCount === 0 ? value.totalCount : totalCount)), operators_1.map(value => value.versions)); : rxjs_1.EMPTY), operators_1.tap(value => console.log(`total3: ${totalCount}, value total3: ${value.totalCount}`)), operators_1.tap(value => (totalCount = totalCount === 0 ? value.totalCount : totalCount)), operators_1.map(value => value.versions));
} }
exports.getVersionIds = getVersionIds; exports.getVersionIds = getVersionIds;
function finalIds(input) { function finalIds(input) {
@@ -47,6 +47,7 @@ function finalIds(input) {
: RATE_LIMIT; : RATE_LIMIT;
console.log(`input.numOldVersionsToDelete: ${input.numOldVersionsToDelete}`); console.log(`input.numOldVersionsToDelete: ${input.numOldVersionsToDelete}`);
return getVersionIds(input.owner, input.repo, input.packageName, input.numOldVersionsToDelete, '', input.token).pipe(operators_1.map(value => { return getVersionIds(input.owner, input.repo, input.packageName, input.numOldVersionsToDelete, '', input.token).pipe(operators_1.map(value => {
console.log(`totalCount in numVersions: ${totalCount}`);
value = value.filter(info => !input.ignoreVersions.test(info.version)); value = value.filter(info => !input.ignoreVersions.test(info.version));
const temp = input.numOldVersionsToDelete; const temp = input.numOldVersionsToDelete;
input.numOldVersionsToDelete = input.numOldVersionsToDelete =
@@ -59,6 +60,7 @@ function finalIds(input) {
} }
else { else {
return getVersionIds(input.owner, input.repo, input.packageName, RATE_LIMIT, '', input.token).pipe(operators_1.map(value => { return getVersionIds(input.owner, input.repo, input.packageName, RATE_LIMIT, '', input.token).pipe(operators_1.map(value => {
console.log(`total count: ${totalCount}`);
totalCount = totalCount =
totalCount - totalCount -
value.filter(info => input.ignoreVersions.test(info.version)).length; value.filter(info => input.ignoreVersions.test(info.version)).length;
+8 -1
View File
@@ -34,7 +34,12 @@ export function getVersionIds(
) )
: EMPTY : EMPTY
), ),
tap(value => (totalCount === 0 ? value.totalCount : totalCount)), tap(value =>
console.log(`total3: ${totalCount}, value total3: ${value.totalCount}`)
),
tap(
value => (totalCount = totalCount === 0 ? value.totalCount : totalCount)
),
map(value => value.versions) map(value => value.versions)
) )
} }
@@ -61,6 +66,7 @@ export function finalIds(input: Input): Observable<string[]> {
input.token input.token
).pipe( ).pipe(
map(value => { map(value => {
console.log(`totalCount in numVersions: ${totalCount}`)
value = value.filter(info => !input.ignoreVersions.test(info.version)) value = value.filter(info => !input.ignoreVersions.test(info.version))
const temp = input.numOldVersionsToDelete const temp = input.numOldVersionsToDelete
input.numOldVersionsToDelete = input.numOldVersionsToDelete =
@@ -83,6 +89,7 @@ export function finalIds(input: Input): Observable<string[]> {
input.token input.token
).pipe( ).pipe(
map(value => { map(value => {
console.log(`total count: ${totalCount}`)
totalCount = totalCount =
totalCount - totalCount -
value.filter(info => input.ignoreVersions.test(info.version)).length value.filter(info => input.ignoreVersions.test(info.version)).length