Skip to content
2 changes: 1 addition & 1 deletion client/db/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function QueryForm () {
<input type='number' className='form-control' id='max-return-length' placeholder='# to Display' value={maxReturnLength} onChange={event => { setMaxReturnLength(event.target.value); }} />
</div>
<div className='input-group col-12 col-xl-6 mb-2'>
<input type='text' className='form-control' id='set-name' placeholder='Set Name' list='set-list' value={setName} onChange={event => { setSetName(event.target.value); }} />
<input type='text' className='form-control' id='set-name' placeholder='Set Name (supports regex, commas)' list='set-list' value={setName} onChange={event => { setSetName(event.target.value); }} />
<datalist id='set-list' />
<button type='button' className='btn btn-danger' id='category-select-button' data-bs-toggle='modal' data-bs-target='#category-modal'>Categories</button>
</div>
Expand Down
8 changes: 7 additions & 1 deletion database/qbreader/get-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,13 @@ function buildQueryAggregation ({ query, difficulties, categories, subcategories
}

if (setName) {
query['set.name'] = setName;
// setName is now an array after being split by commas
if (Array.isArray(setName)) {
query['set.name'] = { $in: setName.map(name => new RegExp(name, 'i')) };
} else {
// Backward compatibility: if setName is a string (shouldn't happen after API route change)
query['set.name'] = { $regex: setName, $options: 'i' };
}
}

if (minYear && maxYear) {
Expand Down
4 changes: 4 additions & 0 deletions routes/api/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ router.get('/', async (req, res) => {
req.query.subcategories = req.query.subcategories.split(',');
}

if (req.query.setName) {
req.query.setName = req.query.setName.split(',').map(s => s.trim());
}

if (!req.query.tossupPagination) {
req.query.tossupPagination = 1;
}
Expand Down
Loading