[ARVADOS] updated: 1.3.0-2905-gf716696e3

Git user git at public.arvados.org
Thu Sep 17 13:43:54 UTC 2020


Summary of changes:
 lib/controller/forecast/controller.go | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

       via  f716696e3cff8dbcacb54817ed053256998ad4bd (commit)
      from  5a2c3c48686ed37a8c1b472fde2a2ff6085b50fc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f716696e3cff8dbcacb54817ed053256998ad4bd
Author: Nico Cesar <nico at nicocesar.com>
Date:   Thu Sep 17 09:32:13 2020 -0400

    Trying out sqlx options and StructScan()
    
    refs #16462
    
    Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico at curii.com>

diff --git a/lib/controller/forecast/controller.go b/lib/controller/forecast/controller.go
index 201584270..f73dfd834 100644
--- a/lib/controller/forecast/controller.go
+++ b/lib/controller/forecast/controller.go
@@ -28,6 +28,11 @@ type Controller struct {
 
 var crs []arvados.ContainerRequest
 
+type wrapperCR struct {
+	arvados.ContainerRequest
+	ID int
+}
+
 // ForecastDatapoints returns the datapoints we have stored in the database
 // for a Container Request UUID. This will follow the specs described in
 // https://dev.arvados.org/projects/arvados/wiki/API_HistoricalForcasting_data_for_CR
@@ -39,13 +44,20 @@ func (ctrl *Controller) ForecastDatapoints(ctx context.Context, opts arvados.Get
 		return
 	}
 
-	query := fmt.Sprintf(`select * from container_requests where requesting_container_uuid = '%s'`, opts.UUID)
-	something, err := tx.QueryContext(ctx, query)
-
+	query := "select * from container_requests where requesting_container_uuid IN (select container_uuid from container_requests where uuid = $1)"
+	var wcr wrapperCR
+	rows, err := tx.QueryxContext(ctx, query, opts.UUID)
 	if err != nil {
 		return
 	}
-	something.Scan(&crs)
+
+	for rows.Next() {
+		err = rows.StructScan(&wcr)
+		if err != nil {
+			return
+		}
+		fmt.Printf("%v", wcr)
+	}
 
 	return
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list