Salt City Watchers | On the Shoulders of Giants

Team Updates

SCW - NASA Space Apps Challenge 2018 - Timelapse


omarjahic14Omar Jahić

Discover starts and galaxy from the image provided via custom made telescope. Area on a image is selected and after that, app returns information about selected area.

omarjahic14Omar Jahić
// model.go
package main
import (
"database/sql"
"fmt"
)
type user struct {
ID int `json:"id"`
UserName string `json:"username"`
Email string `json:"email"`
Password string `json:"password"`
Points string `json:"points"`
}
func (u *user) getUser(db *sql.DB) error {
statement := fmt.Sprintf("SELECT username, email, points FROM users WHERE id=%d", u.ID)
return db.QueryRow(statement).Scan(&u.UserName, &u.Email, &u.Points)
}
func (u *user) updateUser(db *sql.DB) error {
statement := fmt.Sprintf("UPDATE users SET username='%s', email='%s', password='%s', points='%s'WHERE id=%d", u.UserName, u.Email, u.Password, u.Points, u.ID)
_, err := db.Exec(statement)
return err
}
func (u *user) deleteUser(db *sql.DB) error {
statement := fmt.Sprintf("DELETE FROM users WHERE id=%d", u.ID)
_, err := db.Exec(statement)
return err
}
func (u *user) checkEmail(db *sql.DB) error {
statement := fmt.Sprintf("SELECT id FROM users WHERE email='%s'", u.Email)
return db.QueryRow(statement).Scan(&u.ID)
}
func (u *user) createUser(db *sql.DB) error {
statement := fmt.Sprintf("INSERT INTO users(username, email, password, points) VALUES('%s', '%s', '%s', '%s')", u.UserName, u.Email, u.Password, u.Points)
_, err := db.Exec(statement)
if err != nil {
return err
}
err = db.QueryRow("SELECT LAST_INSERT_ID()").Scan(&u.ID)
if err != nil {
return err
}
return nil
}
func getUsers(db *sql.DB, start, count int) ([]user, error) {
statement := fmt.Sprintf("SELECT id, username, email, points FROM users LIMIT %d OFFSET %d", count, start)
rows, err := db.Query(statement)
if err != nil {
return nil, err
}
defer rows.Close()
users := []user{}
for rows.Next() {
var u user
if err := rows.Scan(&u.ID, &u.UserName, &u.Email, &u.Points); err != nil {
return nil, err
}
users = append(users, u)
}
return users, nil
}
// user auth
func (u *user) authUser(db *sql.DB) error {
statement := fmt.Sprintf("SELECT id, username, email FROM users WHERE email='%s' AND password='%s'", u.Email, u.Password)
return db.QueryRow(statement).Scan(&u.ID, &u.UserName, &u.Email)
}
view raw model.go hosted with ❤ by GitHub
tariktzTarik Omercehajic

Backend server written in GO Lang for user registration and points counting.

https://github.com/TarikTz/SCW-SpaceApps2018

tariktzTarik Omercehajic
Team Stream Item
omarjahic14Omar Jahić
Team Stream Item
omarjahic14Omar Jahić
Team Stream Item
omarjahic14Omar Jahić
Team Stream Item
omarjahic14Omar Jahić
Team Stream Item
omarjahic14Omar Jahić
Team Stream Item
omarjahic14Omar Jahić
Team Stream Item
omarjahic14Omar Jahić
NASA Logo

SpaceApps is a NASA incubator innovation program.