-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolved issues #56 and #57: added sourceContentType and pulling FB photos #80
base: master
Are you sure you want to change the base?
Conversation
…ls; removed contentType references from Source model; made changes to item controller and Source model to integrate new model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pulpopurpura Please globally gitignore all .DS_Store files as well and remove them from the commit
@@ -0,0 +1,6 @@ | |||
<component name="InspectionProjectProfileManager"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pulpopurpura I'm not sure why we have this .idea
directory and the corresponding files but we should remove them from the commit and I'd recommend adding them to your global gitignore so they don't get added back in automatically: https://help.github.com/articles/ignoring-files/#create-a-global-gitignore
Gruntfile.js
Outdated
@@ -43,7 +43,8 @@ module.exports = function(grunt) { | |||
}, | |||
nodemon: { | |||
dev: { | |||
script: 'app/server.js' | |||
script: 'app/server.js', | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pulpopurpura This new line should be removed since it seems extraneous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit hard to review the changes since the spaces used for tabbing have been changed in many places and therefore create block-level diffs that don't reveal the real changes easily. Please convert those back so the diff shows only substantive changes.
app/controllers/item.js
Outdated
@@ -31,134 +32,141 @@ var UserSourceAuth = require('app/models/userSourceAuth'); | |||
var UserStorageAuth = require('app/models/userStorageAuth'); | |||
var validateParams = require('app/lib/validateParams'); | |||
|
|||
var util= require('util'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we can remove this module since it's unused.
app/controllers/item.js
Outdated
var queue = kue.createQueue(); | ||
|
||
queue.process('storeItemData', function(queueJob, done) { | ||
debug('process queueJob %s', queueJob.id); | ||
var tools = require('app/lib/utils/debuggingTools'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requires should all take place at the start of the module in alphabetical order unless there's a particular need to place them elsewhere in the module.
app/controllers/item.js
Outdated
} | ||
}); | ||
}; | ||
const STORE_ITEM_DATA = 'storeItemData'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there are a reason for having this be a constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it should never change as it's a string constant -- in general it's better to have these than hard-code strings, even if in a case like this it's a bit overkill as the string was used only once or twice. Just bothered me…
app/controllers/item.js
Outdated
const STORE_ITEM_DATA = 'storeItemData'; | ||
|
||
queue.process(STORE_ITEM_DATA, function(queueJob, done) { | ||
console.log('process queueJob %s', queueJob.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace four-space indentation with two-space throughout all your changes since that's the standard throughout the codebase.
app/controllers/item.js
Outdated
}); | ||
|
||
/** | ||
* Callback resource found at URL. | ||
* (Get resource from passed URL and pass to callback (done) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this comment intentional? In general they shouldn't start with a parenthesis like here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was my notes to myself based on our conversations, trying to make the comment clearer -- I've modified it a bit, removed the ()
…ved .idea and .DS_Store from git, removed references to unused models in item controller.
…e.contentType from tests/controllers/item/itemsGetUrl.js in attempt to correct other test errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the noted formatting issues and add the enable the following for ESLint so they're automatically detected in the future for all contributors. All should use default options unless otherwise specified here.
https://eslint.org/docs/rules/key-spacing
https://eslint.org/docs/rules/func-call-spacing
https://eslint.org/docs/rules/block-spacing
https://eslint.org/docs/rules/array-bracket-spacing
https://eslint.org/docs/rules/keyword-spacing
https://eslint.org/docs/rules/semi-spacing
https://eslint.org/docs/rules/arrow-spacing
https://eslint.org/docs/rules/no-tabs
https://eslint.org/docs/rules/indent (2 spaces)
app/models/source.js
Outdated
itemDataObjectsFromPagePathTemplate: { type: String, default: 'data' }, | ||
// this is where you specifiy what you want from source | ||
// itemsGetUrlTemplate: { type: String, default: 'https://${host}/${contentTypePluralCamelName}?access_token=${accessToken}&limit=${limit}&offset=${offset}' }, | ||
apiVersion: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit looks a lot cleaner than the prior (good work!) but it seems there are still indentation issues, such as here and elsewhere, where I'll note separately. Let's get these resolved too before I review the code for its functional aspects.
app/models/source.js
Outdated
passportStrategy: String, | ||
slug: String, | ||
totalItemsAvailableFromPagePathTemplate: String | ||
itemStorageEnabled: {type: Boolean, default: false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation issue?
app/models/source.js
Outdated
patch: 'admin', | ||
post: 'admin' | ||
} | ||
jsonapi: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation issue?
app/models/sourceContentType.js
Outdated
source: { ref: 'Source',required: true }, | ||
contentType: { ref: 'ContentType',required: true }, | ||
itemsGetUrlTemplate:{ type:String, default: "https://${sourceHost}/${contentTypePluralCamelName}?access_token=${sourceToken}&limit=${sourceItemsLimit}&offset=${offset}"} | ||
source: { ref: 'Source',required: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also watch your spacing. There should be a single space after semi-colons and commas.
app/models/userSourceAuth.js
Outdated
@@ -15,10 +15,10 @@ var queryConditions = require('./queryConditions'); | |||
* @property {module:models/user~User} [user] - User to authenticate at source | |||
*/ | |||
module.exports = modelFactory.new('UserSourceAuth', { | |||
source: { ref: 'Source', required: true }, | |||
source: {ref: 'Source', required: true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing issues
app/models/userSourceAuth.js
Outdated
sourceToken: String, | ||
sourceUser: String, | ||
user: { ref: 'User' } | ||
user: {ref: 'User'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing issues
app/models/source.js
Outdated
contentTypePluralLowercaseName: contentType ? contentType.pluralLowercaseName() : undefined | ||
}); | ||
}, | ||
totalItemsAvailableFromPagePath: function (contentType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove spaces after "function" declarations and the start of parentheses such as here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure -- but it seems to be everywhere -- in a number of files. For instance in models/jobs.js
as well -- I didn't touch that. I did just run ESLint --fix though, but I don't know that that should have changed this. What would you like me to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule is func-call-spacing -- I have added that to .eslintrc.js and it doesn't seem to be flagging anything. Weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe https://eslint.org/docs/rules/func-call-spacing just applies to how functions are executed, not declared. There might be another rule that applies to declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be the rule we need to use for declarations: https://eslint.org/docs/rules/space-before-function-paren
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it is. Thanks --
…her changes in source files)
…nction-paren); fix errors that ESLint detected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More ESLint clean-up =)
.eslintrc.js
Outdated
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These extra lines should be removed. Can you check to see if there is an ESLint to check for extraneous lines inside of objects such as here? And is it possible for ESLint to check its own configuration file?
.gitignore
Outdated
node_modules | ||
.DS_Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two lines should not be in the repo's .gitignore file but rather set as global ignores because they are system-specific, not app-specific: https://help.github.com/articles/ignoring-files/#create-a-global-gitignore
Gruntfile.js
Outdated
@@ -43,7 +43,7 @@ module.exports = function(grunt) { | |||
}, | |||
nodemon: { | |||
dev: { | |||
script: 'app/server.js' | |||
script: 'app/server.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This trailing comma should be removed. Is there an ESLint rule to check automatically for trailing commas such as here?
app/controllers/item.js
Outdated
@@ -31,9 +31,13 @@ var UserSourceAuth = require('app/models/userSourceAuth'); | |||
var UserStorageAuth = require('app/models/userStorageAuth'); | |||
var validateParams = require('app/lib/validateParams'); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this extra line break.
app/controllers/item.js
Outdated
var queue = kue.createQueue(); | ||
|
||
queue.process('storeItemData', function(queueJob, done) { | ||
|
||
const STORE_ITEM_DATA = 'storeItemData'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a reason for this constant. Can you explain or remove it?
app/models/source.js
Outdated
@@ -5,7 +5,9 @@ | |||
|
|||
var modelFactory = require('app/factories/model'); | |||
var nameMethods = require('./methods/name'); | |||
// a way to interporlate strings to get a final URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this comment since the module should be self-documenting.
app/models/source.js
Outdated
var templateCompiler = require('es6-template-strings'); | ||
var SourceContentType = require('app/models/sourceContentType'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please order required modules alphabetically at the top of the file as possible and integrate this rule to enforce: https://eslint.org/docs/rules/sort-imports
app/models/source.js
Outdated
}, | ||
|
||
/** | ||
* @param done {Function} A callback that will be passed a the error (Error) and optionally the sourceContentTypes results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a description for this method
app/models/source.js
Outdated
if (err) { | ||
return done(err); | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this rule should be able to prevent these extra line breaks as well: https://eslint.org/docs/rules/padding-line-between-statements
package.json
Outdated
"supertest": "^3.0.0", | ||
"underscore": "^1.8.3", | ||
"url": "^0.11.0", | ||
"util": "^0.10.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the util module not included in Node by default and therefore doesn't need explicit installation as a package?
…tiple-empty-lines, padded-blocks, padding-line-between-statements, sort-imports, comma-dangle) -- prior to "--fix"
…tiple-empty-lines, padded-blocks, padding-line-between-statements, sort-imports, comma-dangle) -- after "--fix"
.eslintrc.js
Outdated
"func-call-spacing": [ | ||
"error", | ||
"never" | ||
], "block-spacing": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put all value declarations on its own line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.eslintrc.js
Outdated
@@ -32,6 +32,46 @@ module.exports = { | |||
"semi": [ | |||
"warn", | |||
"always" | |||
], | |||
"key-spacing": [ | |||
"warn" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this error instead of warn so issues don't slip through?
remove debugTools module and factor its code to debug module
Remove additions to debug module (from previous commit)
app/controllers/item.js
Outdated
var storeAllItems = function(done) { | ||
debug.start('storeAllItems (contentTypes: %s)', source.contentTypes.length); | ||
async.eachSeries(source.contentTypes, storeAllForUserStorageSourceContentType, done); | ||
let getSourceContentTypesFunction = function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove "Function"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/models/source.js
Outdated
* returns the sourceContentTypes associated with this source | ||
* @param done {Function} A callback that will be passed a the error (Error) and optionally the sourceContentTypes results | ||
*/ | ||
getSourceContentTypesForSource: function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove "ForSource"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/models/source.js
Outdated
* @param done {Function} A callback that will be passed a the error (Error) and optionally the sourceContentTypes results | ||
*/ | ||
getSourceContentTypesForSource: function(done) { | ||
SourceContentType.find({ source: this.id }, function(err, sourceContentTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can replace this inline function passed as a callback to "find" with simply the "done" function since the parameters match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/models/source.js
Outdated
itemDataObjectsFromPagePathTemplate: { type: String, default: 'data' }, | ||
itemsGetUrlTemplate: { type: String, default: 'https://${host}/${contentTypePluralCamelName}?access_token=${accessToken}&limit=${limit}&offset=${offset}' }, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove line break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/models/sourceContentType.js
Outdated
source: { ref: 'Source',required: true }, | ||
contentType: { ref: 'ContentType',required: true }, | ||
itemsGetUrlTemplate: { type: String, default: 'https://${sourceHost}/${contentTypePluralCamelName}?access_token=${sourceToken}&limit=${sourceItemsLimit}&offset=${offset}' } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove line break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/models/sourceContentType.js
Outdated
* @property {module:models/contentType~ContentType} contentType for this sourceContentType | ||
*/ | ||
module.exports = modelFactory.new('SourceContentType', { | ||
source: { ref: 'Source',required: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alphabetical ordering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/models/sourceContentType.js
Outdated
}, { | ||
jsonapi: { | ||
get: 'public', | ||
post: 'public', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the post
and del
values here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
various eslint fixes, move getItemURL from source.js to controllers/item.js, add sourceContentType model to fixtures/model.js
…ferences to sourceContentType to contentType
Resolved git issue #56 and #57 (adding sourceContentType and addressing side effects in item.js, et al.) and grabbing FB photos --