This repository was archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Tracey thomas practice #7
Draft
traceythomasww
wants to merge
9
commits into
intern-practice
Choose a base branch
from
TraceyThomas-Practice
base: intern-practice
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
76fff95
implementation before feedback
8f02a76
refactor draft
54a886f
refactored and post analysis query
c33d556
did not include all files
43a1c32
more refactoring and some tests
e8155c7
tests so far
802e424
missed files
38e3c08
post query unit test not passing
dca7f90
Completed functionality
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or 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,16 @@ | ||
| { | ||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "type": "npm", | ||
| "script": "dev", | ||
| "problemMatcher": [], | ||
| "label": "npm: dev", | ||
| "detail": "nodemon server/app", | ||
| "group": { | ||
| "kind": "build", | ||
| "isDefault": true | ||
| } | ||
| } | ||
| ] | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,34 @@ | ||
| const { Dates } = require('../models/Identifier') | ||
|
|
||
| class DatesDAO { | ||
|
|
||
|
|
||
| getAllDates = () => Dates | ||
|
|
||
| getDate = (name) => { | ||
| //RETURN SINGLE VALUE | ||
| // const formattedName = name.toLowerCase(); | ||
| // for(const date of Dates){ | ||
| // if(date.names.includes(formattedName)){ | ||
| // return [{value: date.value, type: "date"}] | ||
| // } | ||
| // } | ||
| // return [] | ||
|
|
||
| //RETURN MULTIPLE VALUES | ||
| const formatDate = date => {return {value: date.value, type: "date"}} | ||
| const matchingDates = Dates.filter(date => { | ||
| const formattedName = name.toLowerCase() | ||
| return date.names.includes(formattedName) | ||
| }) | ||
| if(!matchingDates) { | ||
| return [] | ||
| } | ||
|
|
||
| return matchingDates.map(formatDate) | ||
|
|
||
|
|
||
| } | ||
|
|
||
| } | ||
| module.exports = DatesDAO |
This file contains hidden or 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,31 @@ | ||
| const {MealTimes} = require('../models/Identifier') | ||
|
|
||
| class MealtimeDAO { | ||
| getAllMealtimes = () => MealTimes | ||
|
|
||
| getMealtime = (type) => { | ||
| //RETURN SINGLE VALUE | ||
| // const formattedType = type.toLowerCase(); | ||
| // for(const mealTime of MealTimes){ | ||
| // if(mealTime.names.includes(formattedType)){ | ||
| // return [{value: mealTime.value, type: "mealtime"}] | ||
| // } | ||
| // } | ||
| // return [] | ||
| // } | ||
|
|
||
| //RETURN MULTIPLE VALUES | ||
| const formatMealTime = mealTime => { return {value: mealTime.value, type: "mealtime"}} | ||
| const matchingMealTimes = MealTimes.filter(mealTime => { | ||
| const formattedType = type.toLowerCase(); | ||
| return mealTime.names.includes(formattedType); | ||
| }) | ||
| if (!matchingMealTimes) { | ||
| return [] | ||
| } | ||
|
|
||
| return matchingMealTimes.map(formatMealTime); | ||
| } | ||
| } | ||
|
|
||
| module.exports = MealtimeDAO |
This file contains hidden or 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,31 @@ | ||
| const stopWordList = require('../models/StopWord') | ||
|
|
||
| class StopwordDAO { | ||
|
|
||
|
|
||
| getAllStopwords = () => stopWordList | ||
|
|
||
|
|
||
| getStopword = (word) => { | ||
| //RETURN SINGLE VALUE | ||
| // const formattedWord = word.toLowerCase() | ||
| // for(const word of stopWordList){ | ||
| // if(word === formattedWord){ | ||
| // return [{value: word, type: "stopword" }] | ||
| // } | ||
| // } | ||
| // return [] | ||
| //RETURN MULTIPLE VALUES{" | ||
| const formatStopword = stopWord => {return {value: stopWord, type: "stopword"}} | ||
| const matchingStopwords = stopWordList.filter(stopword => { | ||
| const formattedWord = word.toLowerCase() | ||
| return stopword === formattedWord | ||
| }) | ||
| if(!matchingStopwords) { | ||
| return [] | ||
| } | ||
|
|
||
| return matchingStopwords.map(formatStopword) | ||
| } | ||
| } | ||
| module.exports = StopwordDAO |
This file contains hidden or 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,13 @@ | ||
| const moment = require('moment'); | ||
|
|
||
| module.exports = [ | ||
| { | ||
| value: moment().format("L"), | ||
| type: "date" | ||
| }, | ||
|
|
||
| { | ||
| value: moment().add(1, 'day').format("L"), | ||
| type: "date" | ||
| } | ||
| ] | ||
This file contains hidden or 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,18 @@ | ||
| const DateDAOClass = require('../DatesDAO') | ||
| const date = new DateDAOClass() | ||
| const dateFixtures = require('../__fixtures__/dates') | ||
| const { Dates } = require('../../models/Identifier') | ||
|
|
||
|
|
||
| describe('Data access getAllDates function test', () => { | ||
| it('should return all dates array', () => { | ||
| const dates = date.getAllDates() | ||
| expect(dates).toEqual(Dates) | ||
| }) | ||
| }) | ||
|
|
||
| describe('Data access getDate function test', () => { | ||
| it('should return all matching dates given named param', () => { | ||
| expect(date.getDate('currently')).toEqual(dateFixtures) | ||
| }) | ||
| }) |
This file contains hidden or 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,17 @@ | ||
| const MealtimeDAOClass = require('../MealtimeDAO') | ||
| const meal = new MealtimeDAOClass() | ||
| const { MealTimes } = require('../../models/Identifier') | ||
|
|
||
| describe('Data access getAllMealtimes function test', () => { | ||
| it('should return all mealtimes array', () => { | ||
| const mealtimes = meal.getAllMealtimes() | ||
| expect(mealtimes).toEqual(MealTimes) | ||
| }) | ||
| }) | ||
|
|
||
| describe('Data access getMealtime function test', () => { | ||
| it('should return all mealtimes matching given param', () => { | ||
| const mealtimesArr = [{value: "morning", type: "mealtime"}, {value: "anytime", type: "mealtime"}] | ||
traceythomasww marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(meal.getMealtime("breakfast")).toEqual(mealtimesArr) | ||
| }) | ||
| }) | ||
This file contains hidden or 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,19 @@ | ||
| const StopwordDAOClass = require('../StopwordDAO') | ||
| const stopWordList = require('../../models/StopWord') | ||
| const stopword = new StopwordDAOClass() | ||
|
|
||
|
|
||
| describe('Data access getAllStopwords function test', () => { | ||
| it('should return all stopwords array', () => { | ||
| const stopwords = stopword.getAllStopwords() | ||
| expect(stopwords).toEqual(stopWordList) | ||
| }) | ||
| }) | ||
|
|
||
| describe('Data access getStopword function test', () => { | ||
| it('should return all stopwords matching given param ', () => { | ||
| const stopwordsArr = [{value: 'on', type: 'stopword'}, {value: 'on', type: 'stopword'}] | ||
| expect(stopword.getStopword('on')).toEqual(stopwordsArr) | ||
| }) | ||
|
|
||
| }) |
This file contains hidden or 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,5 +1,21 @@ | ||
| const express = require('express'); | ||
|
|
||
| const app = express(); | ||
| const PORT = process.env.PORT || 3000; | ||
|
|
||
| //import routers | ||
| const mealtimesRouter = require('./routes/mealtimeRoutes') | ||
| const datesRouter = require('./routes/datesRoutes') | ||
| const stopwordsRouter = require('./routes/stopwordRoutes') | ||
| const postQueryRouter = require('./routes/PostQueryAnalysisRoute') | ||
|
|
||
| //use routers middleware | ||
| app.use('/mealtimes', mealtimesRouter) | ||
| app.use('/dates', datesRouter) | ||
| app.use('/stopwords', stopwordsRouter) | ||
| app.use('/', postQueryRouter) | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| //TODO: Add an express router | ||
| app.listen(PORT, 'localhost') |
This file contains hidden or 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,31 @@ | ||
| const moment = require('moment') | ||
|
|
||
| module.exports = [ | ||
| { | ||
| "status": "success", | ||
| "data": [ | ||
| { | ||
| "value": moment().format("L"), | ||
| "names": [ | ||
| "today", | ||
| "now", | ||
| "currently" | ||
| ] | ||
| }, | ||
| { | ||
| "value": moment().add(-1, 'day').format("L"), | ||
| "names": [ | ||
| "yesterday" | ||
| ] | ||
| }, | ||
| { | ||
| "value": moment().add(1, 'day').format("L"), | ||
| "names": [ | ||
| "tomorrow", | ||
| "currently" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| ] |
This file contains hidden or 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,39 @@ | ||
| module.exports = [ | ||
| { | ||
| "status": "success", | ||
| "data": [ | ||
| { | ||
| "value": "morning", | ||
| "names": [ | ||
| "morning", | ||
| "breakfast", | ||
| "brunch" | ||
| ] | ||
| }, | ||
| { | ||
| "value": "midday", | ||
| "names": [ | ||
| "midday", | ||
| "mid day", | ||
| "lunch" | ||
| ] | ||
| }, | ||
| { | ||
| "value": "evening", | ||
| "names": [ | ||
| "evening", | ||
| "dinner", | ||
| "supper" | ||
| ] | ||
| }, | ||
| { | ||
| "value": "anytime", | ||
| "names": [ | ||
| "anytime", | ||
| "snack", | ||
| "breakfast" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] |
This file contains hidden or 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,27 @@ | ||
| module.exports = [ | ||
| { | ||
| "status": "success", | ||
| "data": [ | ||
| { | ||
| "matchedWord": "abc", | ||
| "type": "unknown", | ||
| "value": "abc" | ||
| }, | ||
| { | ||
| "matchedWord": "not", | ||
| "type": "stopword", | ||
| "value": "not" | ||
| }, | ||
| { | ||
| "matchedWord": "lunch", | ||
| "type": "mealtime", | ||
| "value": "midday" | ||
| }, | ||
| { | ||
| "matchedWord": "today", | ||
| "type": "date", | ||
| "value": "05/17/2021" | ||
| } | ||
| ] | ||
| } | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.