Re: [PATCH] Handle empty resultset getting recent 10 packages

2018-03-20 Thread Nodiv Byzero
Replaced spaces w/ tabs in this version

On Tue, Mar 20, 2018 at 8:47 PM, nodivbyzero  wrote:
> ---
>  web/lib/stats.inc.php | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php
> index 80619fe..f5692f9 100644
> --- a/web/lib/stats.inc.php
> +++ b/web/lib/stats.inc.php
> @@ -19,10 +19,12 @@ function updates_table() {
> $result = $dbh->query($q);
>
> $newest_packages = new ArrayObject();
> -   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> -   $newest_packages->append($row);
> +   if ($result) {
> +   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> +   $newest_packages->append($row);
> +   }
> +   set_cache_value($key, $newest_packages);
> }
> -   set_cache_value($key, $newest_packages);
> }
> include('stats/updates_table.php');
>  }
> --
> 2.16.1
>


[PATCH] Handle empty resultset getting recent 10 packages

2018-03-20 Thread nodivbyzero
---
 web/lib/stats.inc.php | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php
index 80619fe..f5692f9 100644
--- a/web/lib/stats.inc.php
+++ b/web/lib/stats.inc.php
@@ -19,10 +19,12 @@ function updates_table() {
$result = $dbh->query($q);
 
$newest_packages = new ArrayObject();
-   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
-   $newest_packages->append($row);
+   if ($result) {
+   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
+   $newest_packages->append($row);
+   }
+   set_cache_value($key, $newest_packages);
}
-   set_cache_value($key, $newest_packages);
}
include('stats/updates_table.php');
 }
-- 
2.16.1


Re: [PATCH] Handle empty resultset getting recent 10 packages

2018-03-20 Thread Nodiv Byzero
It renders incorrectly main page(Statistics) with empty database.

On Tue, Mar 20, 2018 at 8:33 PM, nodivbyzero  wrote:
> ---
>  web/lib/stats.inc.php | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php
> index 80619fe..0fa3ec6 100644
> --- a/web/lib/stats.inc.php
> +++ b/web/lib/stats.inc.php
> @@ -19,10 +19,13 @@ function updates_table() {
> $result = $dbh->query($q);
>
> $newest_packages = new ArrayObject();
> -   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> -   $newest_packages->append($row);
> -   }
> -   set_cache_value($key, $newest_packages);
> +if ($result) {
> +
> +   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> +   $newest_packages->append($row);
> +   }
> +   set_cache_value($key, $newest_packages);
> +}
> }
> include('stats/updates_table.php');
>  }
> --
> 2.16.1
>


Re: [PATCH] feat(rpc): return "providers" packages when querying by `name` or `name-desc`

2018-03-20 Thread 尤立宇
> An alpm_find_satisifier equivilent is what I want too, thing is once you get
> the package names from that alpm_find_satisifier equivelent what are you
> going to do with thoes names? Probably call "info" on all of them. So why
> not skip that step and just have info support it.
>
> Yes point b is what I was thinking. info("foo") would return "foo" because
> it matches by name, and it would also return "foo-git" because it provides
> "foo". Maybe it would be =info[]=provides[]=name rather than just
> "info". Point being you still get the same hunk of json that info gets you.
>
> Would your type=provides return just package names or the same stuff info
> does? If its the latter it's the same as what I want but under a different
> name.
I'm convinced that just putting that into info would be better.
Looking at the code also shows that adding by[]=provides is easier to implement
as it fits better to the current architecture.


Re: [PATCH] feat(rpc): return "providers" packages when querying by `name` or `name-desc`

2018-03-20 Thread morganamilo



On 21/03/18 02:33, 尤立宇 wrote:

2018-03-21 9:49 GMT+08:00 morganamilo :

I think it would be like:
HTTP GET /rpc/?v=5=provides[]=java-environment[]=libgala.so
{"version":5,"type":"provides","resultcount":2,"results":
   "java-environment": [] // might be list of package names or list of
"info"
   "libgala.so": []
}

Pacman can "-S" and "-Ss" by provides so I would prefer to have the option
to search by provides in type=info and type=search rather than a new
type=provides. Also I would like each option to be indivudually settable, so
"provides", "name" and "desc" can be set indipendantly.

I think I'm looking for an alpm_find_satisifier equivalent rather than
a pacman -Ss equalviant,
and that's why I'm proposing a new type=provides.

For type=info after thinking again, is it
a) The dependencies providers' details are listed in the "Depends"
"MakeDepends" "OptDepends"
b) The "results" items are unchanged, but querying a name not only
returns the package name that matches,
but also their provides array matches. That is
?type=info[]=java-environment would return
resultcount > 1
or something else?

I think b) would work for me, I will just have to verify the version
afterwards with vercmp in that case.


An alpm_find_satisifier equivilent is what I want too, thing is once you get the package 
names from that alpm_find_satisifier equivelent what are you going to do with thoes 
names? Probably call "info" on all of them. So why not skip that step and just 
have info support it.

Yes point b is what I was thinking. info("foo") would return "foo" because it matches by name, and it would also return 
"foo-git" because it provides "foo". Maybe it would be =info[]=provides[]=name rather than just 
"info". Point being you still get the same hunk of json that info gets you.

Would your type=provides return just package names or the same stuff info does? 
If its the latter it's the same as what I want but under a different name.


Re: [PATCH] feat(rpc): return "providers" packages when querying by `name` or `name-desc`

2018-03-20 Thread 尤立宇
2018-03-21 9:49 GMT+08:00 morganamilo :
>> I think it would be like:
>> HTTP GET /rpc/?v=5=provides[]=java-environment[]=libgala.so
>> {"version":5,"type":"provides","resultcount":2,"results":
>>   "java-environment": [] // might be list of package names or list of
>> "info"
>>   "libgala.so": []
>> }
>
> Pacman can "-S" and "-Ss" by provides so I would prefer to have the option
> to search by provides in type=info and type=search rather than a new
> type=provides. Also I would like each option to be indivudually settable, so
> "provides", "name" and "desc" can be set indipendantly.
I think I'm looking for an alpm_find_satisifier equivalent rather than
a pacman -Ss equalviant,
and that's why I'm proposing a new type=provides.

For type=info after thinking again, is it
a) The dependencies providers' details are listed in the "Depends"
"MakeDepends" "OptDepends"
b) The "results" items are unchanged, but querying a name not only
returns the package name that matches,
but also their provides array matches. That is
?type=info[]=java-environment would return
resultcount > 1
or something else?

I think b) would work for me, I will just have to verify the version
afterwards with vercmp in that case.


Re: [PATCH] feat(rpc): return "providers" packages when querying by `name` or `name-desc`

2018-03-20 Thread morganamilo

I think it would be like:
HTTP GET /rpc/?v=5=provides[]=java-environment[]=libgala.so
{"version":5,"type":"provides","resultcount":2,"results":
  "java-environment": [] // might be list of package names or list of "info"
  "libgala.so": []
}
Pacman can "-S" and "-Ss" by provides so I would prefer to have the 
option to search by provides in type=info and type=search rather than a 
new type=provides. Also I would like each option to be indivudually 
settable, so "provides", "name" and "desc" can be set indipendantly.