Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

pulpopurpura
Copy link
Collaborator

Resolved git issue #56 and #57 (adding sourceContentType and addressing side effects in item.js, et al.) and grabbing FB photos --

…ls; removed contentType references from Source model; made changes to item controller and Source model to integrate new model
Copy link
Member

@markmhendrickson markmhendrickson left a 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">
Copy link
Member

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',

Copy link
Member

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

Copy link
Member

@markmhendrickson markmhendrickson left a 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.

@@ -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');
Copy link
Member

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.

var queue = kue.createQueue();

queue.process('storeItemData', function(queueJob, done) {
debug('process queueJob %s', queueJob.id);
var tools = require('app/lib/utils/debuggingTools');
Copy link
Member

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.

}
});
};
const STORE_ITEM_DATA = 'storeItemData';
Copy link
Member

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?

Copy link
Collaborator Author

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…

const STORE_ITEM_DATA = 'storeItemData';

queue.process(STORE_ITEM_DATA, function(queueJob, done) {
console.log('process queueJob %s', queueJob.id);
Copy link
Member

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.

});

/**
* Callback resource found at URL.
* (Get resource from passed URL and pass to callback (done)
Copy link
Member

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.

Copy link
Collaborator Author

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
Copy link
Member

@markmhendrickson markmhendrickson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Member

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.

passportStrategy: String,
slug: String,
totalItemsAvailableFromPagePathTemplate: String
itemStorageEnabled: {type: Boolean, default: false},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation issue?

patch: 'admin',
post: 'admin'
}
jsonapi: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation issue?

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 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation issue?

Copy link
Member

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.

@@ -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},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing issues

sourceToken: String,
sourceUser: String,
user: { ref: 'User' }
user: {ref: 'User'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing issues

contentTypePluralLowercaseName: contentType ? contentType.pluralLowercaseName() : undefined
});
},
totalItemsAvailableFromPagePath: function (contentType) {
Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha!

Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is. Thanks --

Copy link
Member

@markmhendrickson markmhendrickson left a 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
]

Copy link
Member

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
Copy link
Member

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',
Copy link
Member

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?

@@ -31,9 +31,13 @@ var UserSourceAuth = require('app/models/userSourceAuth');
var UserStorageAuth = require('app/models/userStorageAuth');
var validateParams = require('app/lib/validateParams');


Copy link
Member

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.

var queue = kue.createQueue();

queue.process('storeItemData', function(queueJob, done) {

const STORE_ITEM_DATA = 'storeItemData';
Copy link
Member

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?

@@ -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
Copy link
Member

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.

var templateCompiler = require('es6-template-strings');
var SourceContentType = require('app/models/sourceContentType');
Copy link
Member

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

},

/**
* @param done {Function} A callback that will be passed a the error (Error) and optionally the sourceContentTypes results
Copy link
Member

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

if (err) {
return done(err);
} else {

Copy link
Member

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",
Copy link
Member

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": [
Copy link
Member

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.

Copy link
Collaborator Author

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"
Copy link
Member

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)
var storeAllItems = function(done) {
debug.start('storeAllItems (contentTypes: %s)', source.contentTypes.length);
async.eachSeries(source.contentTypes, storeAllForUserStorageSourceContentType, done);
let getSourceContentTypesFunction = function(done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove "Function"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove "ForSource"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @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) {
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

itemDataObjectsFromPagePathTemplate: { type: String, default: 'data' },
itemsGetUrlTemplate: { type: String, default: 'https://${host}/${contentTypePluralCamelName}?access_token=${accessToken}&limit=${limit}&offset=${offset}' },

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove line break

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

source: { ref: 'Source',required: true },
contentType: { ref: 'ContentType',required: true },
itemsGetUrlTemplate: { type: String, default: 'https://${sourceHost}/${contentTypePluralCamelName}?access_token=${sourceToken}&limit=${sourceItemsLimit}&offset=${offset}' }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove line break

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @property {module:models/contentType~ContentType} contentType for this sourceContentType
*/
module.exports = modelFactory.new('SourceContentType', {
source: { ref: 'Source',required: true },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetical ordering

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}, {
jsonapi: {
get: 'public',
post: 'public',
Copy link
Member

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.

Copy link
Collaborator Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants