Skip to content

Commit

Permalink
improve search (#1201)
Browse files Browse the repository at this point in the history
* improve search
  • Loading branch information
alyxbb authored Dec 15, 2024
1 parent 1bde253 commit ad5dc23
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
20 changes: 17 additions & 3 deletions src/Classes/ServiceAPI/MyRadio_Podcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -903,18 +903,32 @@ public function getCover()

/**
* Searches searchable *text* metadata for the specified value. Does not work for image metadata.
*
* if $q is set, then $path_query must be set to "search". This allows the query to be given in path or in parameters.
*
* @todo effective_from/to not yet implemented
*
* @param string $query The query value.
* @param string $path_query The query value encoded in the path (DEPRECATED).
* @param string $q The query value as a query string. to use this, $path_query must be set to "search"
* @param array $string_keys The metadata keys to search
* @param int $effective_from UTC Time to search from.
* @param int $effective_to UTC Time to search to.
*
* @return array The shows that match the search terms
*/
public static function searchMeta($query, $string_keys = null, $effective_from = null, $effective_to = null)
public static function searchMeta($path_query, $q="", $string_keys = null, $effective_from = null, $effective_to = null)
{
if($path_query != "search" && $q != "") {
throw new MyRadioException(
"the path_query must be set to 'search' if q is set in the query string",
400
);
}
if ($path_query == "search" && $q != ""){
$query = $q;
} else {
$query = $path_query;
}
if (is_null($string_keys)) {
$string_keys = ['title', 'description', 'tag'];
}
Expand Down
17 changes: 15 additions & 2 deletions src/Classes/ServiceAPI/MyRadio_Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -1028,18 +1028,31 @@ public static function getMostListened($date = 0)

/**
* Searches searchable *text* metadata for the specified value. Does not work for image metadata.
* if $q is set, then $path_query must be set to "search". This allows the query to be given in path or in parameters.
*
* @todo effective_from/to not yet implemented
*
* @param string $query The query value.
* @param string $path_query The query value encoded in the path (DEPRECATED).
* @param string $q The query value as a query string. to use this, $path_query must be set to "search"
* @param array $string_keys The metadata keys to search
* @param int $effective_from UTC Time to search from.
* @param int $effective_to UTC Time to search to.
*
* @return array The shows that match the search terms
*/
public static function searchMeta($query, $string_keys = null, $effective_from = null, $effective_to = null)
public static function searchMeta($path_query, $q="", $string_keys = null, $effective_from = null, $effective_to = null)
{
if($path_query != "search" && $q != "") {
throw new MyRadioException(
"the path_query must be set to 'search' if q is set in the query string",
400
);
}
if ($path_query == "search" && $q != ""){
$query = $q;
} else {
$query = $path_query;
}
if (is_null($string_keys)) {
$string_keys = ['title', 'description', 'tag'];
}
Expand Down

0 comments on commit ad5dc23

Please sign in to comment.