| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. | 1 // Copyright 2016 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 return merr | 354 return merr |
| 355 } | 355 } |
| 356 | 356 |
| 357 // GetAllConsoles returns all registered projects with the builder name. | 357 // GetAllConsoles returns all registered projects with the builder name. |
| 358 // If builderName is empty, then this retrieves all Consoles. | 358 // If builderName is empty, then this retrieves all Consoles. |
| 359 func GetAllConsoles(c context.Context, builderName string) ([]*Console, error) { | 359 func GetAllConsoles(c context.Context, builderName string) ([]*Console, error) { |
| 360 q := datastore.NewQuery("Console") | 360 q := datastore.NewQuery("Console") |
| 361 if builderName != "" { | 361 if builderName != "" { |
| 362 q = q.Eq("Builders", builderName) | 362 q = q.Eq("Builders", builderName) |
| 363 } | 363 } |
| 364 q.Order("ID") | |
| 365 con := []*Console{} | 364 con := []*Console{} |
| 366 err := datastore.GetAll(c, q, &con) | 365 err := datastore.GetAll(c, q, &con) |
| 367 return con, err | 366 return con, err |
| 368 } | 367 } |
| 369 | 368 |
| 370 // GetConsole returns the requested console. | 369 // GetConsole returns the requested console. |
| 371 func GetConsole(c context.Context, proj, id string) (*Console, error) { | 370 func GetConsole(c context.Context, proj, id string) (*Console, error) { |
| 372 // TODO(hinoka): Memcache this. | 371 // TODO(hinoka): Memcache this. |
| 373 con := Console{ | 372 con := Console{ |
| 374 Parent: datastore.MakeKey(c, "Project", proj), | 373 Parent: datastore.MakeKey(c, "Project", proj), |
| 375 ID: id, | 374 ID: id, |
| 376 } | 375 } |
| 377 err := datastore.Get(c, &con) | 376 err := datastore.Get(c, &con) |
| 378 return &con, err | 377 return &con, err |
| 379 } | 378 } |
| OLD | NEW |