1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

allow searching by cleaned map name

This commit is contained in:
Robin Appelman 2017-09-12 17:47:21 +02:00
commit 7a68627054
2 changed files with 8 additions and 5 deletions

View file

@ -60,7 +60,10 @@ class DemoListProvider extends BaseProvider {
->leftJoin('d', 'upload_blacklist', 'b', $query->expr()->eq('uploader_id', 'uploader')) ->leftJoin('d', 'upload_blacklist', 'b', $query->expr()->eq('uploader_id', 'uploader'))
->where($query->expr()->isNull('b.id')); ->where($query->expr()->isNull('b.id'));
if (isset($where['map'])) { if (isset($where['map'])) {
$query->where($query->expr()->eq('map', $query->createNamedParameter($where['map']))); $query->where($query->expr()->orX(
$query->expr()->eq('clean_map_name(map)', $query->createNamedParameter($where['map'])),
$query->expr()->eq('map', $query->createNamedParameter($where['map']))
));
} }
if (isset($where['playerCount'])) { if (isset($where['playerCount'])) {
$query->where($query->expr()->in('"playerCount"', $query->where($query->expr()->in('"playerCount"',

View file

@ -71,11 +71,11 @@ class DemoListProviderTest extends TestCase {
} }
public function testFilterMap() { public function testFilterMap() {
$id1 = $this->demoProvider->storeDemo($this->getDemo(1, 'map1'), 'foo', 'bar'); $id1 = $this->demoProvider->storeDemo($this->getDemo(1, 'map_foo'), 'foo', 'bar');
$id2 = $this->demoProvider->storeDemo($this->getDemo(1, 'map2'), 'foo', 'bar'); $id2 = $this->demoProvider->storeDemo($this->getDemo(1, 'map_bar'), 'foo', 'bar');
$id3 = $this->demoProvider->storeDemo($this->getDemo(1, 'map1'), 'foo', 'bar'); $id3 = $this->demoProvider->storeDemo($this->getDemo(1, 'map_foo'), 'foo', 'bar');
$list = $this->demoListProvider->listDemos(1, ['map' => 'map1']); $list = $this->demoListProvider->listDemos(1, ['map' => 'map_foo']);
$this->assertCount(2, $list); $this->assertCount(2, $list);
$this->assertEquals($id3, $list[0]->getId()); $this->assertEquals($id3, $list[0]->getId());