import re

with open('backend/src/db/api/job_logs.js', 'r') as f:
    content = f.read()

replacement = '''      {
        model: db.vehicles,
        as: 'vehicle',
        
        where: filter.vehicle ? {
          [Op.or]: [
            { id: { [Op.in]: filter.vehicle.split('|').map(term => Utils.uuid(term)) } },
            {
              name: {
                [Op.or]: filter.vehicle.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
              }
            },
          ]
        } : {},
        
      },
      
      {
        model: db.workers_comp_classes,
        as: 'workersCompClass',
        where: filter.workersCompClass ? {
          [Op.or]: [
            { id: { [Op.in]: filter.workersCompClass.split('|').map(term => Utils.uuid(term)) } },
            {
              name: {
                [Op.or]: filter.workersCompClass.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
              }
            },
          ]
        } : {},
      },'''

content = content.replace(
    '''      {
        model: db.vehicles,
        as: 'vehicle',
        
        where: filter.vehicle ? {
          [Op.or]: [
            { id: { [Op.in]: filter.vehicle.split('|').map(term => Utils.uuid(term)) } },
            {
              name: {
                [Op.or]: filter.vehicle.split('|').map(term => ({ [Op.iLike]: `%${term}%` }))
              }
            },
          ]
        } : {},
        
      },''',
    replacement
)

with open('backend/src/db/api/job_logs.js', 'w') as f:
    f.write(content)

print("Patched include!")
