@@ -49,7 +49,7 @@ class SeatsService {
4949 async getAssignee ( id : number ) {
5050 const Seats = mongoose . model ( 'Seats' ) ;
5151 const Member = mongoose . model ( 'Member' ) ;
52- const member = await Member . findOne ( { id } ) . sort ( { org : - 1 } ) ; //this temporarily resolves a bug where one org fails but the other one succeeds
52+ const member = await Member . findOne ( { id } ) . sort ( { org : - 1 } ) ; //this temporarily resolves a bug where one org fails but the other one succeeds
5353
5454 if ( ! member ) {
5555 throw `Member with id ${ id } not found`
@@ -91,6 +91,38 @@ class SeatsService {
9191 const Seats = mongoose . model ( 'Seats' ) ;
9292 const ActivityTotals = mongoose . model ( 'ActivityTotals' ) ;
9393
94+ // fill the data to 10,000 entries for testing
95+ // data = new Array(10000).fill(0).map((entry, index) => {
96+ // const seat = data[index % data.length];
97+ // return {
98+ // ...seat,
99+ // plan_type: seat.plan_type || 'unknown',
100+ // assignee: {
101+ // ...seat.assignee,
102+ // id: seat.assignee.id + index,
103+ // login: seat.assignee.login ||
104+ // `test-login-${index}`,
105+ // node_id: seat.assignee.node_id || `test-node-id-${index}`,
106+ // avatar_url: seat.assignee.avatar_url ||
107+ // `https://avatars.githubusercontent.com/u/${index}?v=4`,
108+ // gravatar_id: seat.assignee.gravatar_id || `test-gravatar-id-${index}`,
109+ // url: seat.assignee.url || `https://api.github.com/users/test-login-${index}`,
110+ // html_url: seat.assignee.html_url || ``,
111+ // followers_url: seat.assignee.followers_url || `https://api.github.com/users/test-login-${index}/followers`,
112+ // following_url: seat.assignee.following_url || `https://api.github.com/users/test-login-${index}/following{/other_user}`,
113+ // gists_url: seat.assignee.gists_url || `https://api.github.com/users/test-login-${index}/gists{/gist_id}`,
114+ // starred_url: seat.assignee.starred_url || `https://api.github.com/users/test-login-${index}/starred{/owner}{/repo}`,
115+ // subscriptions_url: seat.assignee.subscriptions_url || `https://api.github.com/users/test-login-${index}/subscriptions`,
116+ // organizations_url: seat.assignee.organizations_url || `https://api.github.com/users/test-login-${index}/orgs`,
117+ // repos_url: seat.assignee.repos_url || `https://api.github.com/users/test-login-${index}/repos`,
118+ // events_url: seat.assignee.events_url || `https://api.github.com/users/test-login-${index}/events{/privacy}`,
119+ // received_events_url: seat.assignee.received_events_url || `https://api.github.com/users/test-login-${index}/received_events`,
120+ // type: seat.assignee.type || `User`,
121+ // site_admin: seat.assignee.site_admin || false
122+ // }
123+ // }
124+ // });
125+
94126 logger . info ( `Inserting ${ data . length } seat assignments for ${ org } ` ) ;
95127
96128 const memberUpdates = data . map ( seat => ( {
@@ -123,6 +155,7 @@ class SeatsService {
123155 upsert : true ,
124156 }
125157 } ) ) ;
158+
126159 logger . debug ( `Writing ${ memberUpdates . length } members` ) ;
127160 await Members . bulkWrite ( memberUpdates ) ;
128161
0 commit comments