Skip to content

Commit

Permalink
fix: filter out non-user organization in the rank (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Apr 12, 2024
1 parent 40f68b9 commit a41d893
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/getUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ import { UsersDataBase } from './common/props.js';
return item
}, []);

result = result.map((item: UsersDataBase, idx: number) => {
item.rank = idx + 1;
return item;
});
result = result
.filter(item => item.type === 'User')
.map((item: UsersDataBase, idx: number) => {
item.rank = idx + 1;
return item;
});

FS.outputFileSync(path.join(process.cwd(), '.cache', 'users.json'), JSON.stringify(result, null, 2));
console.log(`-> 共获取\x1b[32;1m${result.length}\x1b[0m条用户数据!`);
} catch (error) {
console.log(error);
}
})()
})()
12 changes: 7 additions & 5 deletions src/getUsersChina.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ import { UsersDataBase } from './common/props.js';
return item
}, []);

result = result.map((item: UsersDataBase, idx: number) => {
item.rank = idx + 1;
return item;
});
result = result
.filter(item => item.type === 'User')
.map((item: UsersDataBase, idx: number) => {
item.rank = idx + 1;
return item;
});

FS.outputFileSync(path.join(process.cwd(), '.cache', 'users.china.json'), JSON.stringify(result, null, 2));
console.log(`-> 共获取\x1b[32;1m${result.length}\x1b[0m条用户数据!`);
} catch (error) {
console.log(error);
}
})()
})()

0 comments on commit a41d893

Please sign in to comment.