Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from HackIllinois/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
ASankaran authored Aug 5, 2018
2 parents 3e6c5b4 + 1285bd7 commit 5ef2301
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 27 deletions.
39 changes: 12 additions & 27 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,11 @@ trap cleanup INT

function cleanup {
echo "Cleaning up services"
pgrep "api" | xargs kill
pgrep "hackillinois-" | xargs kill
rm -rf log/
exit 0
}

function install {
go install github.com/HackIllinois/api-gateway
go install github.com/HackIllinois/api-auth
go install github.com/HackIllinois/api-user
go install github.com/HackIllinois/api-registration
go install github.com/HackIllinois/api-decision
go install github.com/HackIllinois/api-rsvp
go install github.com/HackIllinois/api-checkin
go install github.com/HackIllinois/api-upload
go install github.com/HackIllinois/api-mail
go install github.com/HackIllinois/api-event
go install github.com/HackIllinois/api-stat
}

function auth {
export GITHUB_CLIENT_ID=
export GITHUB_CLIENT_SECRET=
Expand All @@ -37,15 +23,15 @@ function auth {
export AUTH_PORT=:8002
export USER_SERVICE=http://localhost:8003

api-auth &
hackillinois-api-auth &
}

function user {
export USER_DB_HOST=localhost
export USER_DB_NAME=user
export USER_PORT=:8003

api-user &
hackillinois-api-user &
}

function registration {
Expand All @@ -57,7 +43,7 @@ function registration {
export DECISION_SERVICE=http://localhost:8005
export MAIL_SERVICE=http://localhost:8009

api-registration &
hackillinois-api-registration &
}

function decision {
Expand All @@ -66,7 +52,7 @@ function decision {
export DECISION_PORT=:8005
export MAIL_SERVICE=http://localhost:8009

api-decision &
hackillinois-api-decision &
}

function rsvp {
Expand All @@ -77,7 +63,7 @@ function rsvp {
export DECISION_SERVICE=http://localhost:8005
export MAIL_SERVICE=http://localhost:8009

api-rsvp &
hackillinois-api-rsvp &
}

function checkin {
Expand All @@ -87,15 +73,15 @@ function checkin {
export RSVP_SERVICE=http://localhost:8006
export REGISTRATION_SERVICE=http://localhost:8004

api-checkin &
hackillinois-api-checkin &
}

function upload {
export UPLOAD_PORT=:8008
export S3_REGION=us-east-1
export S3_BUCKET=hackillinois-upload-2019

api-upload &
hackillinois-api-upload &
}

function mail {
Expand All @@ -105,7 +91,7 @@ function mail {
export USER_SERVICE=http://localhost:8003
export MAIL_PORT=:8009

api-mail &
hackillinois-api-mail &
}

function event {
Expand All @@ -114,15 +100,15 @@ function event {
export EVENT_PORT=:8010
export CHECKIN_SERVICE=http://localhost:8007

api-event &
hackillinois-api-event &
}

function stat {
export STAT_DB_HOST=localhost
export STAT_DB_NAME=stat
export STAT_PORT=:8011

api-stat &
hackillinois-api-stat &
}

function gateway {
Expand All @@ -142,10 +128,9 @@ function gateway {
mkdir log/
touch log/access.log

api-gateway -u &
hackillinois-api-gateway -u &
}

install
auth
user
registration
Expand Down
25 changes: 25 additions & 0 deletions services/registration/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/gorilla/mux"
"github.com/justinas/alice"
"net/http"
"time"
)

func SetupController(route *mux.Route) {
Expand Down Expand Up @@ -109,6 +110,9 @@ func CreateCurrentUserRegistration(w http.ResponseWriter, r *http.Request) {
user_registration.FirstName = user_info.FirstName
user_registration.LastName = user_info.LastName

user_registration.CreatedAt = time.Now().Unix()
user_registration.UpdatedAt = time.Now().Unix()

err = service.CreateUserRegistration(id, user_registration)

if err != nil {
Expand Down Expand Up @@ -165,11 +169,20 @@ func UpdateCurrentUserRegistration(w http.ResponseWriter, r *http.Request) {
panic(errors.UnprocessableError(err.Error()))
}

original_registration, err := service.GetUserRegistration(id)

if err != nil {
panic(errors.UnprocessableError(err.Error()))
}

user_registration.GitHub = user_info.Username
user_registration.Email = user_info.Email
user_registration.FirstName = user_info.FirstName
user_registration.LastName = user_info.LastName

user_registration.CreatedAt = original_registration.CreatedAt
user_registration.UpdatedAt = time.Now().Unix()

err = service.UpdateUserRegistration(id, user_registration)

if err != nil {
Expand Down Expand Up @@ -247,6 +260,9 @@ func CreateCurrentMentorRegistration(w http.ResponseWriter, r *http.Request) {
mentor_registration.FirstName = user_info.FirstName
mentor_registration.LastName = user_info.LastName

mentor_registration.CreatedAt = time.Now().Unix()
mentor_registration.UpdatedAt = time.Now().Unix()

err = service.CreateMentorRegistration(id, mentor_registration)

if err != nil {
Expand Down Expand Up @@ -289,11 +305,20 @@ func UpdateCurrentMentorRegistration(w http.ResponseWriter, r *http.Request) {
panic(errors.UnprocessableError(err.Error()))
}

original_registration, err := service.GetMentorRegistration(id)

if err != nil {
panic(errors.UnprocessableError(err.Error()))
}

mentor_registration.GitHub = user_info.Username
mentor_registration.Email = user_info.Email
mentor_registration.FirstName = user_info.FirstName
mentor_registration.LastName = user_info.LastName

mentor_registration.CreatedAt = original_registration.CreatedAt
mentor_registration.UpdatedAt = time.Now().Unix()

err = service.UpdateMentorRegistration(id, mentor_registration)

if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions services/registration/models/mentor_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ type MentorRegistration struct {
ShirtSize string `json:"shirtSize" validate:"required,oneof=S M L XL"`
GitHub string `json:"github" validate:"required"`
Linkedin string `json:"linkedin" validate:"required"`
CreatedAt int64 `json:"createdAt" validate:"required"`
UpdatedAt int64 `json:"updatedAt" validate:"required"`
}
2 changes: 2 additions & 0 deletions services/registration/models/user_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type UserRegistration struct {
ExtraInfos []UserExtraInfo `json:"extraInfos" validate:"required,dive,required"`
OsContributors []UserOsContributor `json:"osContributors" validate:"required,dive,required"`
Collaborators []UserCollaborator `json:"collaborators" validate:"required,dive,required"`
CreatedAt int64 `json:"createdAt" validate:"required"`
UpdatedAt int64 `json:"updatedAt" validate:"required"`
}

type UserLongForm struct {
Expand Down
4 changes: 4 additions & 0 deletions services/registration/tests/registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ var base_user_registration models.UserRegistration = models.UserRegistration{
Github: "collaboratorgithub",
},
},
CreatedAt: 10,
UpdatedAt: 15,
}

var base_mentor_registration models.MentorRegistration = models.MentorRegistration{
Expand All @@ -359,4 +361,6 @@ var base_mentor_registration models.MentorRegistration = models.MentorRegistrati
ShirtSize: "M",
GitHub: "githubusername",
Linkedin: "linkedinusername",
CreatedAt: 10,
UpdatedAt: 15,
}

0 comments on commit 5ef2301

Please sign in to comment.