@@ -113,6 +113,56 @@ export class JobController {
113113 return this . jobService . findByTag ( tagName , paginationArgs , orderBy ) ;
114114 }
115115
116+ /**
117+ * Fetch new jobs from Reddit and Web3Career, store them, and send notifications
118+ */
119+ @Get ( 'fetch' )
120+ @Api ( {
121+ summary : 'Fetch new jobs from Reddit and Web3Career' ,
122+ description : 'Fetches new jobs from both sources, stores them, and sends notifications.' ,
123+ responses : [ { status : 200 , description : 'Jobs fetched and notifications sent.' } ] ,
124+ } )
125+ async fetchJobs ( ) : Promise < { redditJobs : any [ ] ; web3CareerJobs : any [ ] ; summary : any } > {
126+ 6 ;
127+
128+ // Fetch Reddit jobs
129+ const redditSubreddits = [ 'remotejs' , 'remotejobs' , 'forhire' , 'jobs' , 'webdevjobs' ] ;
130+ const redditPosts = await this . redditService . fetchRedditPosts ( redditSubreddits ) ;
131+ const redditJobs = await this . redditService . storeRedditJobPosts ( redditPosts ) ;
132+
133+ // Fetch Web3Career jobs
134+ const web3CareerRawJobs = await this . web3CareerService . fetchWeb3CareerJobs ( ) ;
135+ const web3CareerJobs = await this . web3CareerService . storeWeb3CareerJobs ( web3CareerRawJobs ) ;
136+
137+ // Create summary
138+ const summary = {
139+ totalFetched : redditPosts . length + web3CareerRawJobs . length ,
140+ totalAdded : redditJobs . length + web3CareerJobs . length ,
141+ totalSkipped : redditPosts . length - redditJobs . length + ( web3CareerRawJobs . length - web3CareerJobs . length ) ,
142+ reddit : {
143+ fetched : redditPosts . length ,
144+ added : redditJobs . length ,
145+ skipped : redditPosts . length - redditJobs . length ,
146+ } ,
147+ web3career : {
148+ fetched : web3CareerRawJobs . length ,
149+ added : web3CareerJobs . length ,
150+ skipped : web3CareerRawJobs . length - web3CareerJobs . length ,
151+ } ,
152+ } ;
153+
154+ this . logger . info (
155+ `Job fetch summary:
156+ Total Fetched: ${ summary . totalFetched }
157+ Reddit: ${ summary . reddit . fetched }
158+ Web3Career: ${ summary . web3career . fetched }
159+ Total Added: ${ summary . totalAdded }
160+ Total Skipped: ${ summary . totalSkipped } `
161+ ) ;
162+
163+ return { redditJobs, web3CareerJobs, summary} ;
164+ }
165+
116166 /**
117167 * Create a new job listing
118168 * Creates a new job entry in the database with the provided information
@@ -193,52 +243,4 @@ export class JobController {
193243 async remove ( @Param ( 'id' , ParseIntPipe ) id : number , @User ( ) user : any ) {
194244 return this . jobService . remove ( id , user . id ) ;
195245 }
196-
197- /**
198- * Fetch new jobs from Reddit and Web3Career, store them, and send notifications
199- */
200- @Get ( 'fetch' )
201- @Api ( {
202- summary : 'Fetch new jobs from Reddit and Web3Career' ,
203- description : 'Fetches new jobs from both sources, stores them, and sends notifications.' ,
204- responses : [ { status : 200 , description : 'Jobs fetched and notifications sent.' } ] ,
205- } )
206- async fetchJobs ( ) : Promise < { redditJobs : any [ ] ; web3CareerJobs : any [ ] ; summary : any } > {
207- // Fetch Reddit jobs
208- const redditSubreddits = [ 'remotejs' , 'remotejobs' , 'forhire' , 'jobs' , 'webdevjobs' ] ;
209- const redditPosts = await this . redditService . fetchRedditPosts ( redditSubreddits ) ;
210- const redditJobs = await this . redditService . storeRedditJobPosts ( redditPosts ) ;
211-
212- // Fetch Web3Career jobs
213- const web3CareerRawJobs = await this . web3CareerService . fetchWeb3CareerJobs ( ) ;
214- const web3CareerJobs = await this . web3CareerService . storeWeb3CareerJobs ( web3CareerRawJobs ) ;
215-
216- // Create summary
217- const summary = {
218- totalFetched : redditPosts . length + web3CareerRawJobs . length ,
219- totalAdded : redditJobs . length + web3CareerJobs . length ,
220- totalSkipped : redditPosts . length - redditJobs . length + ( web3CareerRawJobs . length - web3CareerJobs . length ) ,
221- reddit : {
222- fetched : redditPosts . length ,
223- added : redditJobs . length ,
224- skipped : redditPosts . length - redditJobs . length ,
225- } ,
226- web3career : {
227- fetched : web3CareerRawJobs . length ,
228- added : web3CareerJobs . length ,
229- skipped : web3CareerRawJobs . length - web3CareerJobs . length ,
230- } ,
231- } ;
232-
233- this . logger . info (
234- `Job fetch summary:
235- Total Fetched: ${ summary . totalFetched }
236- Reddit: ${ summary . reddit . fetched }
237- Web3Career: ${ summary . web3career . fetched }
238- Total Added: ${ summary . totalAdded }
239- Total Skipped: ${ summary . totalSkipped } `
240- ) ;
241-
242- return { redditJobs, web3CareerJobs, summary} ;
243- }
244246}
0 commit comments