Search by provides in RPC interface
Hi, knowing you already added the possibility to search by depends, optdepends, makedepends and checkdepends in the AUR RPC interface, could you think about also add the possibility to search by provides: https://aur.archlinux.org/rpc/?v=5&type=search&by=provides&arg=<keyword> It could be very useful for AUR helpers to solve AUR dependencies this way. If you point me to the relevant code, I can try to provide a patch. Regards, Guillaume.
On 10/25/18 at 05:26pm, Guillaume Benoit wrote:
Hi, knowing you already added the possibility to search by depends, optdepends, makedepends and checkdepends in the AUR RPC interface, could you think about also add the possibility to search by provides: https://aur.archlinux.org/rpc/?v=5&type=search&by=provides&arg=<keyword>
It could be very useful for AUR helpers to solve AUR dependencies this way.
If you point me to the relevant code, I can try to provide a patch.
I can't, but there was discussion about it earlier: https://www.mail-archive.com/aur-dev@archlinux.org/msg04171.html -- Jelle van der Waa
--- On Thu, Oct 25, 2018 at 3:26 PM Guillaume Benoit <guillaume@manjaro.org> wrote:
If you point me to the relevant code, I can try to provide a patch.
Not an aurweb developer, but since I looked at it recently and it was fresh on my mind, here's a draft, only-cursorily-tested patch. web/lib/aurjson.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index c51e9c2..5de6533 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -18,11 +18,15 @@ class AurJSON { ); private static $exposed_fields = array( 'name', 'name-desc', 'maintainer', - 'depends', 'makedepends', 'checkdepends', 'optdepends' + 'depends', 'makedepends', 'checkdepends', 'optdepends', + 'conflicts', 'provides', 'replaces' ); private static $exposed_depfields = array( 'depends', 'makedepends', 'checkdepends', 'optdepends' ); + private static $exposed_relfields = array( + 'conflicts', 'provides', 'replaces' + ); private static $fields_v1 = array( 'Packages.ID', 'Packages.Name', 'PackageBases.ID AS PackageBaseID', @@ -510,6 +514,19 @@ class AurJSON { $subquery .= "AND DependencyTypes.Name = $search_by"; $where_condition = "$keyword_string IN ($subquery)"; } + } else if (in_array($search_by, self::$exposed_relfields)) { + if (empty($keyword_string)) { + return $this->json_error('Query arg is empty.'); + } else { + $keyword_string = $this->dbh->quote($keyword_string); + $search_by = $this->dbh->quote($search_by); + $subquery = "SELECT PackageRelations.RelName FROM PackageRelations "; + $subquery .= "LEFT JOIN RelationTypes "; + $subquery .= "ON PackageRelations.RelTypeID = RelationTypes.ID "; + $subquery .= "WHERE PackageRelations.PackageID = Packages.ID "; + $subquery .= "AND RelationTypes.Name = $search_by"; + $where_condition = "$keyword_string IN ($subquery)"; + } } return $this->process_query('search', $where_condition); -- 2.19.1
On Thu, 25 Oct 2018 at 21:44:46, Vladimir Panteleev wrote:
--- On Thu, Oct 25, 2018 at 3:26 PM Guillaume Benoit <guillaume@manjaro.org> wrote:
If you point me to the relevant code, I can try to provide a patch.
Not an aurweb developer, but since I looked at it recently and it was fresh on my mind, here's a draft, only-cursorily-tested patch.
There is another patch [1] with a slightly different approach that still needs to be reviewed and merged. [1] https://lists.archlinux.org/pipermail/aur-dev/2018-June/004544.html
Le 26/10/2018 à 06:48, Lukas Fleischer a écrit :
On Thu, 25 Oct 2018 at 21:44:46, Vladimir Panteleev wrote:
--- On Thu, Oct 25, 2018 at 3:26 PM Guillaume Benoit <guillaume@manjaro.org> wrote:
If you point me to the relevant code, I can try to provide a patch. Not an aurweb developer, but since I looked at it recently and it was fresh on my mind, here's a draft, only-cursorily-tested patch. There is another patch [1] with a slightly different approach that still needs to be reviewed and merged.
[1] https://lists.archlinux.org/pipermail/aur-dev/2018-June/004544.html
The patch from Li-Yu Yu is more consequent than Vladimir Panteleev one but both seem fine.
participants (4)
-
Guillaume Benoit
-
Jelle van der Waa
-
Lukas Fleischer
-
Vladimir Panteleev