Skip to content

Commit

Permalink
88: Fixed filtering transcoder log on input string and uri
Browse files Browse the repository at this point in the history
  • Loading branch information
njbrunner committed Aug 21, 2024
1 parent cb44ca6 commit 9dd812a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
20 changes: 11 additions & 9 deletions anms-core/anms/routes/transcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ async def paged_transcoder_log(params: Params = Depends()):
return await paginate(session, select(TranscoderLog).order_by(desc(TranscoderLog.transcoder_log_id)), params)


@router.get("/db/search/{query}", status_code=status.HTTP_200_OK, response_model=Page[TL])
@router.get("/db/search/{query:path}", status_code=status.HTTP_200_OK, response_model=Page[TL])
async def paged_transcoder_log(query: str, params: Params = Depends()):
async with get_async_session() as session:
query = '%' + query + '%'

return await paginate(session, select(TranscoderLog).where(or_(
TranscoderLog.transcoder_log_id.ilike(query),
TranscoderLog.input_string.ilike(query),
TranscoderLog.uri.ilike(query),
TranscoderLog.cbor.ilike(query)
)).order_by(desc(TranscoderLog.transcoder_log_id)), params)
filters = []
filters.append(TranscoderLog.input_string.ilike(f'%{query}%'))
filters.append(TranscoderLog.uri.ilike(f'%{query}%'))
filters.append(TranscoderLog.cbor.ilike(f'%{query}%'))
if query.isdigit():
filters.append(TranscoderLog.transcoder_log_id == int(query))

return await paginate(session, select(TranscoderLog)
.where(or_(*filters))
.order_by(desc(TranscoderLog.transcoder_log_id)), params)

@router.get("/db/id/{id}", status_code=status.HTTP_200_OK, response_model=TL)
async def transcoder_log_by_id(id: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<input
type="text"
class="form-control"
placeholder="Search by ID String, URI, or CBOR"
placeholder="Search by ID, Input String, URI, or CBOR"
v-model="searchString"
@change="handleSearchStringChange($event)"
v-on:keyup.enter="handlePageChange(1)"
Expand Down Expand Up @@ -142,7 +142,6 @@ export default {
// vm.setPage(1);
// vm.reloadTranscoderLog();
},
handleSearchStringChange(event) {
const vm = this;
vm.setSearchString(event.target.value);
Expand Down
2 changes: 1 addition & 1 deletion anms-ui/server/components/transcoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
return next(Boom.badData('Invalid size=' + req.query.size));
}
const params = {'page': req.query.page, 'size': req.query.size };
const url = utils.generateAnmsCoreUrl(['transcoder', 'db', 'search', transcoderQuery], params);
const url = utils.generateAnmsCoreUrl(['transcoder', 'db', 'search', encodeURIComponent(transcoderQuery)], params);
console.log("[getTranscoderPagedBySearch]: url");
console.log(url);
const transcoderLog = await axios.get(url);
Expand Down

0 comments on commit 9dd812a

Please sign in to comment.