about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--db_actions.go14
1 files changed, 14 insertions, 0 deletions
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(&timestep)
+	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