I guess I don't see the need for this.
If you want to see 'new packages', just use the rss feed.
Dumping this in the rcp api seems... wrong to me.

On Mon, Oct 5, 2009 at 3:02 PM, Laszlo Papp <djsza...@gmail.com> wrote:
> From: Laszlo Papp <djsza...@gmail.com>
>
>        Add a json interface for the newly submitted packages output,
>        after a query operation, and it will be easier to handle it from
>        a frontend for example.
>
> Signed-off-by: Laszlo Papp <djsz...@archlinux.us>
> ---
>  web/html/rpc.php          |    1 +
>  web/lib/aurjson.class.php |   32 +++++++++++++++++++++++++++++++-
>  2 files changed, 32 insertions(+), 1 deletions(-)
>
> diff --git a/web/html/rpc.php b/web/html/rpc.php
> index 240cad1..52e5603 100644
> --- a/web/html/rpc.php
> +++ b/web/html/rpc.php
> @@ -19,6 +19,7 @@ if ( $_SERVER['REQUEST_METHOD'] == 'GET' ) {
>         echo '<li>search</li>';
>         echo '<li>info</li>';
>         echo '<li>msearch</li>';
> +        echo '<li>newpackages</li>';
>         echo '</ul><br />';
>         echo 'Each method requires the following HTTP GET syntax:<br />';
>         echo '&nbsp;&nbsp; type=<i>methodname</i>&arg=<i>data</i> <br /><br 
> />';
> diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
> index 251203a..884e327 100644
> --- a/web/lib/aurjson.class.php
> +++ b/web/lib/aurjson.class.php
> @@ -18,7 +18,7 @@ include_once("aur.inc");
>  **/
>  class AurJSON {
>     private $dbh = false;
> -    private $exposed_methods = array('search','info','msearch');
> +    private $exposed_methods = 
> array('search','info','msearch','newpackages');
>     private $fields = array('Packages.ID','Name','Version','CategoryID',
>        'Description', 'LocationID', 'URL','URLPath','License','NumVotes',
>        'OutOfDate');
> @@ -116,6 +116,36 @@ class AurJSON {
>     }
>
>     /**
> +      * Returns the latest packages from the database.
> +      * @param $quantity_integer how much packages should return.
> +      * @return mixed Returns an array with the latests quantity_integer 
> packages.
> +      **/
> +     private function newpackages($quantity_integer) {
> +           echo $keywrd_string;
> +         if ($quantity_integer <= 0) {
> +             return $this->json_error('Quantity should be positive');
> +         }
> +
> +         $query = "SELECT " . implode(',', $this->fields) .
> +             " FROM Packages ORDER BY SubmittedTS DESC LIMIT 0," 
> .$quantity_integer;
> +
> +         $result = db_query($query, $this->dbh);
> +
> +         if ( $result && (mysql_num_rows($result) > 0) ) {
> +             $search_data = array();
> +             while ( $row = mysql_fetch_assoc($result) ) {
> +                 array_push($search_data, $row);
> +             }
> +
> +             mysql_free_result($result);
> +             return $this->json_results('newpackages', $search_data);
> +         }
> +         else {
> +             return $this->json_error('No results found');
> +         }
> +     }
> +
> +    /**
>      * Returns the info on a specific package.
>      * @param $pqdata The ID or name of the package. Package Query Data.
>      * @return mixed Returns an array of value data containing the package 
> data
> --
> 1.6.4.4
>
>

Reply via email to