From 5bf3571855448d47da788ee9a628def96481c8ec Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 17 Feb 2019 00:29:38 +0100 Subject: implemented a function getting a stars timestep --- db_actions.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/db_actions.go b/db_actions.go index 1e5689b..c6ed041 100644 --- a/db_actions.go +++ b/db_actions.go @@ -524,6 +524,20 @@ func GetStar(starID int64) structs.Star2D { return star } +// getStarIDTimestep returns the timestep the given starID is currently inside of +func GetStarIDTimestep(starID int64) int64 { + var timestep int64 + + // get the star from the stars table + query := fmt.Sprintf("SELECT timestep FROM nodes WHERE star_id=%d", starID) + err := db.QueryRow(query).Scan(×tep) + if err != nil { + log.Fatalf("[ E ] GetStar query: %v \n\t\t\tquery: %s\n", err, query) + } + + return timestep +} + // getStarMass returns the mass if the star with the given ID func getStarMass(starID int64) float64 { var mass float64 -- cgit 1.4.1