-
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.
- Loading branch information
Showing
6 changed files
with
64 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE OR REPLACE FUNCTION get_day (u_id integer, sday date) | ||
RETURNS TABLE (id integer, "start" date, "title" text, "allDay" boolean) AS $$ | ||
DECLARE | ||
BEGIN | ||
RETURN QUERY | ||
SELECT d.id, d.start, p.name || ' - ' || w.name AS "title", true AS "allDay" | ||
FROM days d | ||
INNER JOIN workouts w ON d.workout_id = w.id | ||
INNER JOIN phases p ON d.phase_id = p.id | ||
WHERE d.user_id = u_id AND d.start = sday; | ||
END; | ||
$$ language plpgsql; |
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
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,25 @@ | ||
'use strict'; | ||
|
||
var Schedule = require('../../../models/schedule'), | ||
Joi = require('joi'); | ||
|
||
module.exports = { | ||
description: 'Get 1 scheduled workouts for user', | ||
tags:['workouts', 'schedule'], | ||
validate: { | ||
params: { | ||
date: Joi.date().required() | ||
} | ||
}, | ||
cors: { | ||
origin: ['http://localhost:8100'], | ||
credentials: true | ||
}, | ||
handler: function(request, reply){ | ||
var params = {date: request.params.date, userId:request.auth.credentials.id}; | ||
Schedule.findOne(params, function(err, schedule){ | ||
if(err){console.log('ERROR: Workout.getPhases', err);} | ||
reply({schedule:schedule}).code(err ? 418 : 200); | ||
}); | ||
} | ||
}; |
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,20 +1,21 @@ | ||
'use strict'; | ||
|
||
module.exports = [ | ||
{method: 'get', path: '/{param*}', config: require('./config/static/static')}, | ||
{method: 'post', path: '/register', config: require('./config/users/register')}, | ||
{method: 'post', path: '/login', config: require('./config/users/login')}, | ||
{method: 'delete', path: '/logout', config: require('./config/users/logout')}, | ||
{method: 'get', path: '/status', config: require('./config/users/status')}, | ||
{method: 'get', path: '/regimes', config: require('./config/workouts/query_regimes')}, | ||
{method: 'post', path: '/regimes', config: require('./config/workouts/add_regime')}, | ||
{method: 'get', path: '/regimes/{rid}/phases', config: require('./config/workouts/query_phases')}, | ||
{method: 'post', path: '/phases', config: require('./config/workouts/add_phase')}, | ||
{method: 'get', path: '/phases/{id}/workouts', config: require('./config/workouts/query_workouts')}, | ||
{method: 'get', path: '/workouts/day/{id}', config: require('./config/workouts/find_by_day')}, | ||
{method: 'post', path: '/workouts', config: require('./config/workouts/add_workout')}, | ||
{method: 'delete', path: '/workouts/{id}', config: require('./config/workouts/delete_workout')}, | ||
{method: 'post', path: '/workouts/schedule', config: require('./config/schedule/schedule_workout')}, | ||
{method: 'get', path: '/workouts/schedule', config: require('./config/schedule/query_schedule')}, | ||
{method: 'delete', path: '/workouts/day/{id}', config: require('./config/schedule/delete_day')} | ||
{method: 'get', path: '/{param*}', config: require('./config/static/static')}, | ||
{method: 'post', path: '/register', config: require('./config/users/register')}, | ||
{method: 'post', path: '/login', config: require('./config/users/login')}, | ||
{method: 'delete', path: '/logout', config: require('./config/users/logout')}, | ||
{method: 'get', path: '/status', config: require('./config/users/status')}, | ||
{method: 'get', path: '/regimes', config: require('./config/workouts/query_regimes')}, | ||
{method: 'post', path: '/regimes', config: require('./config/workouts/add_regime')}, | ||
{method: 'get', path: '/regimes/{rid}/phases', config: require('./config/workouts/query_phases')}, | ||
{method: 'post', path: '/phases', config: require('./config/workouts/add_phase')}, | ||
{method: 'get', path: '/phases/{id}/workouts', config: require('./config/workouts/query_workouts')}, | ||
{method: 'get', path: '/workouts/day/{id}', config: require('./config/workouts/find_by_day')}, | ||
{method: 'post', path: '/workouts', config: require('./config/workouts/add_workout')}, | ||
{method: 'delete', path: '/workouts/{id}', config: require('./config/workouts/delete_workout')}, | ||
{method: 'post', path: '/workouts/schedule', config: require('./config/schedule/schedule_workout')}, | ||
{method: 'get', path: '/workouts/schedule', config: require('./config/schedule/query_schedule')}, | ||
{method: 'get', path: '/workouts/schedule/{date}', config: require('./config/schedule/get_day')}, | ||
{method: 'delete', path: '/workouts/day/{id}', config: require('./config/schedule/delete_day')} | ||
]; |
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