-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port Fitness over from main website to standalone app
- Loading branch information
1 parent
b932b4f
commit 22b18d4
Showing
34 changed files
with
2,589 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"presets": ["env", "stage-1", "react"], | ||
"plugins": ["transform-class-properties", "syntax-dynamic-import"] | ||
"plugins": ["transform-class-properties", "syntax-dynamic-import", "./babelPluginRelay"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var babelRelayPlugin = require('babel-relay-plugin') | ||
var schemaData = require('./fitnessSchema.json').data | ||
var plugin = babelRelayPlugin(schemaData) | ||
|
||
module.exports = plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env bash | ||
docker exec postgres-starter /bin/bash -c "psql -U postgres links < schema.sql" | ||
docker exec postgres-starter /bin/bash -c "psql -U postgres links < seed.sql" | ||
export NODE_ENV="development" | ||
docker exec postgres-fitness /bin/bash -c "psql -U postgres fitness < schema.sql" | ||
docker exec postgres-fitness /bin/bash -c "psql -U postgres fitness < seed.sql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
import humps from 'humps' | ||
|
||
export default (pgPool) => { | ||
// queries here | ||
return { | ||
getLinks() { | ||
getWorkouts() { | ||
return pgPool.query(` | ||
select * from links | ||
`).then(res => humps.camelizeKeys(res.rows)) | ||
select * from workouts | ||
`).then(res => { | ||
return humps.camelizeKeys(res.rows) | ||
}) | ||
}, | ||
addLink({ link, linkTitle, createdAt }) { | ||
getWorkoutsByDate(date) { | ||
return pgPool.query(` | ||
insert into links("link", "link_title", "created_at") | ||
select * from workouts | ||
where workout_date = $1 | ||
`, [date]).then(res => { | ||
return humps.camelizeKeys(res.rows) | ||
}) | ||
}, | ||
addNewWorkout( | ||
{ | ||
workout, workoutDate, duration, calories, fatBurnTime, fitnessTime, avgHeartRate, maxHeartRate, workoutType | ||
}) { | ||
return pgPool.query(` | ||
insert into workouts("workout", | ||
"workout_date", | ||
"duration", | ||
"calories", | ||
"fat_burn_time", | ||
"fitness_time", | ||
"avg_heart_rate", | ||
"max_heart_rate", | ||
"workout_type") | ||
values | ||
($1, $2, $3) | ||
($1, $2, $3, $4, $5, $6, $7, $8, $9) | ||
returning * | ||
`, [link, linkTitle, createdAt]).then(res => { | ||
`, [workout, workoutDate, duration, calories, fatBurnTime, fitnessTime, avgHeartRate, maxHeartRate, | ||
workoutType]).then(res => { | ||
return humps.camelizeKeys(res.rows[0]) | ||
}) | ||
}, | ||
deleteLink({ id }) { | ||
return pgPool.query(` | ||
delete from links where id=$1 | ||
returning * | ||
`, [id]).then(res => humps.camelizeKeys(res.rows[0])) | ||
}, | ||
updateLink({ id, link, linkTitle }) { | ||
return pgPool.query(` | ||
update links | ||
set link=$1, | ||
link_title=$2 | ||
where id=$3 | ||
returning * | ||
`, [link, linkTitle, id]).then(res => humps.camelizeKeys(res.rows[0])) | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
version: "2" | ||
|
||
services: | ||
postgres_starter: | ||
image: postgres:starter | ||
container_name: "postgres-starter" | ||
postgres_fitness: | ||
image: postgres:fitness | ||
container_name: "postgres-fitness" | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
- POSTGRES_DB=links | ||
- POSTGRES_DB=fitness | ||
|
Oops, something went wrong.