Skip to content

Commit

Permalink
Merge pull request #558 from sloganking/fix-duplicate-answers
Browse files Browse the repository at this point in the history
  • Loading branch information
feder-cr authored Oct 18, 2024
2 parents 4f63902 + f9230a4 commit d52c8ed
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/aihawk_easy_applier.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,13 @@ def _select_dropdown_option(self, element: WebElement, text: str) -> None:
def _save_questions_to_json(self, question_data: dict) -> None:
output_file = 'answers.json'
question_data['question'] = self._sanitize_text(question_data['question'])

# Check if the question already exists in the JSON file and bail out if it does
for item in self.all_data:
if self._sanitize_text(item['question']) == question_data['question'] and item['type'] == question_data['type']:
logger.debug(f"Question already exists in answers.json. Aborting save of: {item['question']}")
return

logger.debug(f"Saving question data to JSON: {question_data}")
try:
try:
Expand All @@ -847,6 +854,7 @@ def _save_questions_to_json(self, question_data: dict) -> None:
data.append(question_data)
with open(output_file, 'w') as f:
json.dump(data, f, indent=4)
self.all_data = data
logger.debug("Question data saved successfully to JSON")
except Exception:
tb_str = traceback.format_exc()
Expand Down

0 comments on commit d52c8ed

Please sign in to comment.