GetProject fetches project object for specified name (database hash or project name alias).
(db *gorp.DbMap, name string)
| 61 | |
| 62 | // GetProject fetches project object for specified name (database hash or project name alias). |
| 63 | func GetProject(db *gorp.DbMap, name string) (p *Project, err error) { |
| 64 | // if the alias fits to a hash, query using database id |
| 65 | var h hash.Hash |
| 66 | err = hash.Decode(&h, name) |
| 67 | if err == nil { |
| 68 | err = db.SelectOne(&p, `SELECT * FROM "project" WHERE "database_id" = ? LIMIT 1`, name) |
| 69 | } |
| 70 | |
| 71 | if err == nil { |
| 72 | return |
| 73 | } |
| 74 | |
| 75 | err = db.SelectOne(&p, `SELECT * FROM "project" WHERE "alias" = ? LIMIT 1`, name) |
| 76 | if err != nil { |
| 77 | err = errors.Wrapf(err, "get project failed") |
| 78 | } |
| 79 | return |
| 80 | } |
| 81 | |
| 82 | // GetProjectByID fetches the project object using project database id. |
| 83 | func GetProjectByID(db *gorp.DbMap, dbID proto.DatabaseID, developer int64) (p *Project, err error) { |
no test coverage detected