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 4 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
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,14 @@ | ||
| const { Dates } = require('../models/Identifier') | ||
|
|
||
| class DatesDAO { | ||
|
|
||
|
|
||
| getAllDates = () => Dates | ||
|
|
||
| getDate = (name) => { | ||
| let timeFound = Dates.find(ele => ele.names.includes(name.toLowerCase()) ? ele.value : null) | ||
| return timeFound ? [{ value: timeFound.value, type: 'date'}] : [] | ||
| } | ||
|
|
||
| } | ||
| 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,19 @@ | ||
| const {MealTimes} = require('../models/Identifier') | ||
|
|
||
| class MealtimeDAO { | ||
|
|
||
|
|
||
| getAllMealtimes = () => MealTimes | ||
|
|
||
| getMealtime = (type) => { | ||
| let mealtimeFound | ||
| MealTimes.forEach(ele => { | ||
| if(ele.names.includes(type.toLowerCase())){ | ||
| mealtimeFound = ele.value | ||
| } | ||
| }) | ||
| return mealtimeFound ? [{value: mealtimeFound, type: "mealtime"}] : [] | ||
| } | ||
| } | ||
|
|
||
| module.exports = MealtimeDAO | ||
Empty file.
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,15 @@ | ||
| const stopWordList = require('../models/StopWord') | ||
|
|
||
| class StopwordDAO { | ||
|
|
||
|
|
||
| getAllStopwords = () => stopWordList | ||
|
|
||
|
|
||
| getStopword = (word) => { | ||
| const wordFound = stopWordList.find(ele => ele === word.toLowerCase()) | ||
|
|
||
| return wordFound ? [{value: wordFound, type: "stopword"} ] : [] | ||
| } | ||
| } | ||
| 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 |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| const express = require('express'); | ||
|
|
||
| const app = express(); | ||
| const PORT = process.env.PORT || 3000; | ||
|
|
||
| //import routers | ||
| const mealtimesRouter = require('./routes/mealtimesRoutes') | ||
| const datesRouter = require('./routes/datesRoutes') | ||
| const stopwordsRouter = require('./routes/stopwordsRoutes') | ||
| const postQueryRouter = require('./routes/postQueryAnalysis') | ||
|
|
||
| //use routers middleware | ||
| app.use('/', mealtimesRouter) | ||
| app.use('/', datesRouter) | ||
| app.use('/', 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
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,36 @@ | ||
| const dateParser = require('../services/Parser') | ||
traceythomasww marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const parseIt = new dateParser() | ||
| const express = require('express'); | ||
| const { all } = require('./mealtimesRoutes'); | ||
| const router = express.Router() | ||
|
|
||
|
|
||
| router.get('/dates', (req, res) => { | ||
| let dateReturned | ||
| try{ | ||
| const { date } = req.query | ||
| if(date){ | ||
| dateReturned = parseIt.getDate(date) | ||
| } | ||
| const allDates = parseIt.getAllDates() | ||
| let data = !dateReturned ? allDates : dateReturned | ||
|
|
||
| if(data.length < 1){ | ||
traceythomasww marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return res.json({ | ||
| status: 'failure', | ||
| data | ||
| }) | ||
| }else{ | ||
| return res.json({ | ||
| status: 'success', | ||
| data | ||
| }) | ||
traceythomasww marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| }catch(err){ | ||
| console.log(err) | ||
| } | ||
| }) | ||
|
|
||
|
|
||
|
|
||
| module.exports = router | ||
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 mealtimeParser = require('../services/Parser') | ||
| const parseIt = new mealtimeParser() | ||
| const express = require('express'); | ||
| const router = express.Router() | ||
|
|
||
| router.get('/mealtimes', (req, res) => { | ||
| let value | ||
| try{ | ||
| const { name } = req.query | ||
| if(name){ | ||
| value = parseIt.getMealtime(name) | ||
| } | ||
| const allMealtimes = parseIt.getAllMealtimes() | ||
| let data = !value ? allMealtimes : value | ||
| if(data.length < 1){ | ||
| return res.json({ | ||
| status: 'failure', | ||
| data | ||
| }) | ||
| }else{ | ||
| return res.json({ | ||
| status: 'success', | ||
| data | ||
| }) | ||
| } | ||
|
|
||
|
|
||
| }catch(err){ | ||
| console.log(err) | ||
| } | ||
| }) | ||
|
|
||
|
|
||
| module.exports = router |
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,47 @@ | ||
| const stopwordParser = require('../services/Parser') | ||
| const parseIt = new stopwordParser() | ||
| const express = require('express'); | ||
| const router = express.Router() | ||
|
|
||
| let regex = /[^0-9a-z\s]/ig | ||
|
|
||
| router.post('/', (req, res) => { | ||
| try{ | ||
| let { query } = req.query | ||
| let queryArr = query.replace(regex, '').split(' ') | ||
| let data = [] | ||
|
|
||
|
|
||
| for(let i = 0; i < queryArr.length; i++) { | ||
| let dateVal = parseIt.getDate(queryArr[i]) | ||
| let mealtimeVal = parseIt.getMealtime(queryArr[i]) | ||
| let stopwordVal = parseIt.getStopword(queryArr[i]) | ||
traceythomasww marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if(dateVal.length > 0){ | ||
| let dateValues = dateVal[0] | ||
traceythomasww marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| data.push({matchedWord: queryArr[i], type: dateValues.type, value: dateValues.value}) | ||
|
|
||
| } | ||
| if(mealtimeVal.length > 0){ | ||
| let mealtimeValues = mealtimeVal[0] | ||
| data.push({matchedWord: queryArr[i], type: mealtimeValues.type, value: mealtimeValues.value}) | ||
|
|
||
| } | ||
| if(stopwordVal.length > 0){ | ||
| let stopwordValues = stopwordVal[0] | ||
| data.push({matchedWord: queryArr[i], type: stopwordValues.type, value: stopwordValues.value}) | ||
|
|
||
| }else{ | ||
| data.push({matchedWord: queryArr[i], type: 'unknown', value: queryArr[i].toLowerCase()}) | ||
| } | ||
traceythomasww marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return res.json({ | ||
| data | ||
| }) | ||
traceythomasww marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }catch(err) { | ||
| console.log(err) | ||
| } | ||
|
|
||
| }) | ||
|
|
||
| module.exports = router | ||
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 stopwordParser = require('../services/Parser') | ||
| const parseIt = new stopwordParser() | ||
| const express = require('express'); | ||
| const router = express.Router() | ||
|
|
||
|
|
||
| router.get('/stopwords', (req, res) => { | ||
| let wordFound | ||
| try{ | ||
| const { word } = req.query | ||
| if(word) { | ||
| wordFound = parseIt.getStopword(word) | ||
| } | ||
| const allStopwords = parseIt.getAllStopwords() | ||
| let data = !wordFound ? allStopwords : wordFound | ||
| if(data.length < 1){ | ||
| res.json({ | ||
| status: 'failure', | ||
| data | ||
| }) | ||
| }else{ | ||
| res.json({ | ||
| status: 'success', | ||
| data | ||
| }) | ||
| } | ||
| }catch(err){ | ||
| console.log(err) | ||
| } | ||
| }) | ||
| module.exports = router |
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,8 +1,30 @@ | ||
| const {MealTimes, Dates} = require('../models/Identifier'); | ||
| const StopWord = require('../models/StopWord'); | ||
| const DatesDAO = require('../DAO/DatesDAO') | ||
| const MealtimeDAO = require('../DAO/MealtimeDAO') | ||
| const StopwordDAO = require('../DAO/StopwordDAO') | ||
|
|
||
|
|
||
|
|
||
| class Parser { | ||
| //TODO Parse through and identify all StopWords & Identifiers | ||
|
|
||
| //Dates Functions | ||
| datesdao = new DatesDAO() | ||
| getAllDates = () => this.datesdao.getAllDates() | ||
| getDate = (time) => this.datesdao.getDate(time) | ||
traceythomasww marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| //Mealtime Functions | ||
| mealtimedao = new MealtimeDAO() | ||
| getAllMealtimes = () => this.mealtimedao.getAllMealtimes() | ||
| getMealtime = (type) => this.mealtimedao.getMealtime(type) | ||
|
|
||
| //Stopword Functions | ||
| stopworddao = new StopwordDAO() | ||
| getAllStopwords = () => this.stopworddao.getAllStopwords() | ||
| getStopword = (word) => this.stopworddao.getStopword(word) | ||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
| module.exports = Parser; | ||
|
|
||
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.