Skip to content

Commit

Permalink
Port Fitness over from main website to standalone app
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjaspreet committed Feb 21, 2017
1 parent b932b4f commit 22b18d4
Show file tree
Hide file tree
Showing 34 changed files with 2,589 additions and 273 deletions.
2 changes: 1 addition & 1 deletion .babelrc
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"]
}
5 changes: 5 additions & 0 deletions babelPluginRelay.js
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
5 changes: 2 additions & 3 deletions bootstrap.sh
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"
7 changes: 4 additions & 3 deletions client.webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ module.exports = {
module: {
rules: [
{
use: 'babel-loader',
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/
},
{
use: ['style-loader', 'css-loader'],
test: /\.css$/
test: /\.css$/,
use: ['style-loader', 'css-loader?modules'],
exclude: /node_modules/
}
]
},
Expand Down
53 changes: 31 additions & 22 deletions database/pgdb.js
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]))

}
}
}
8 changes: 4 additions & 4 deletions docker-compose.yml
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

Loading

0 comments on commit 22b18d4

Please sign in to comment.