Rename types so they make sense
This commit is contained in:
14
main.go
14
main.go
@@ -108,7 +108,7 @@ func getTasks(c *gin.Context) {
|
|||||||
|
|
||||||
func completeTask(c *gin.Context) {
|
func completeTask(c *gin.Context) {
|
||||||
// get the task data from the request
|
// get the task data from the request
|
||||||
var completedTask historyReqData
|
var completedTask newHistoryData
|
||||||
if err := c.BindJSON(&completedTask); err != nil {
|
if err := c.BindJSON(&completedTask); err != nil {
|
||||||
c.IndentedJSON(http.StatusBadRequest, completedTask)
|
c.IndentedJSON(http.StatusBadRequest, completedTask)
|
||||||
return
|
return
|
||||||
@@ -129,12 +129,12 @@ func completeTask(c *gin.Context) {
|
|||||||
|
|
||||||
func getHistory(c *gin.Context) {
|
func getHistory(c *gin.Context) {
|
||||||
// get the log of past points gained
|
// get the log of past points gained
|
||||||
var history []historyReqData
|
var history []newHistoryData
|
||||||
// get array of all historyReqData
|
// get array of all history Data
|
||||||
rows, err := db.Query("SELECT * FROM history")
|
rows, err := db.Query("SELECT * FROM history")
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var tempHistoryData historyReqData
|
var tempHistoryData newHistoryData
|
||||||
err = rows.Scan(&tempHistoryData.UID, &tempHistoryData.TID, &tempHistoryData.Time, &tempHistoryData.PointsGained)
|
err = rows.Scan(&tempHistoryData.UID, &tempHistoryData.TID, &tempHistoryData.Time, &tempHistoryData.PointsGained)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.IndentedJSON(http.StatusNotFound, history)
|
c.IndentedJSON(http.StatusNotFound, history)
|
||||||
@@ -144,12 +144,12 @@ func getHistory(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
rows.Close()
|
rows.Close()
|
||||||
|
|
||||||
var historyRes []historyResData
|
var historyRes []historyData
|
||||||
// make the data human-readable
|
// make the data human-readable
|
||||||
for i := 0; i < len(history); i++ {
|
for i := 0; i < len(history); i++ {
|
||||||
var tempHistory historyResData
|
var tempHistory historyData
|
||||||
// get the username
|
// get the username
|
||||||
var tempUser loginOutput
|
var tempUser userData
|
||||||
stmt, err := db.Prepare("SELECT * FROM users WHERE uid=?")
|
stmt, err := db.Prepare("SELECT * FROM users WHERE uid=?")
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
err = stmt.QueryRow(history[i].UID).Scan(&tempUser.UID, &tempUser.Name, &tempUser.Password, &tempUser.Role)
|
err = stmt.QueryRow(history[i].UID).Scan(&tempUser.UID, &tempUser.Name, &tempUser.Password, &tempUser.Role)
|
||||||
|
|||||||
Reference in New Issue
Block a user