1616post .add_argument ('company' , required = True , type = str , location = 'args' )
1717post .add_argument ('location' , required = True , type = str , location = 'args' )
1818post .add_argument ('date_posted' , required = True , type = str , location = 'args' )
19- post .add_argument ('description ' , required = True , type = str , location = 'args' )
19+ post .add_argument ('custom_description ' , required = False , type = str , location = 'args' )
2020
2121delete = reqparse .RequestParser ()
2222delete .add_argument ('id' , required = True , type = str , location = 'args' )
@@ -61,7 +61,7 @@ def post(self):
6161 'company' : args ['company' ],
6262 'location' : args ['location' ],
6363 'date_posted' : args ['date_posted' ],
64- 'description ' : args ['description ' ]
64+ 'custom_description ' : args ['custom_description ' ]
6565 }
6666
6767 tmp = []
@@ -71,7 +71,7 @@ def post(self):
7171 # append the new jobs to the existing ones
7272 tmp .append (job )
7373 else :
74- tmp = job
74+ tmp . append ( job )
7575
7676 with open (currentDir + '/data.json' , 'w' , encoding = 'utf-8' ) as file :
7777 json .dump (tmp , file , indent = 4 )
@@ -114,17 +114,31 @@ class RefreshJobs(Resource):
114114 def get (self ):
115115 jobs = scrapeJobs ()
116116
117+ simple_jobs = []
118+
119+ for job in jobs :
120+ new_job = {
121+ 'id' : job ['id' ],
122+ 'job_url' : job ['job_url' ],
123+ 'title' : job ['title' ],
124+ 'company' : job ['company' ],
125+ 'location' : job ['location' ],
126+ 'date_posted' : job ['date_posted' ],
127+ }
128+
129+ simple_jobs .append (new_job )
130+
117131 tmp = []
118132 if os .path .exists (currentDir + '/data.json' ):
119133 with open (currentDir + '/data.json' , 'r' , encoding = 'utf-8' ) as file :
120134 tmp = json .load (file )
121135 # append the new jobs to the existing ones
122- tmp += jobs
136+ tmp += simple_jobs
123137 else :
124- tmp = jobs
138+ tmp = simple_jobs
125139
126140 with open (currentDir + '/data.json' , 'w' , encoding = 'utf-8' ) as file :
127141 json .dump (tmp , file , indent = 4 )
128- return f"jobs scraped: { len (jobs )} . Total { len (tmp )} " , 200
142+ return f"jobs scraped: { len (simple_jobs )} . Total { len (tmp )} " , 200
129143
130144# class HardReset TODO: beware will remove it all maybe PURGE would be better?
0 commit comments