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

[WIP] challenges and dits #66

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

[WIP] challenges and dits #66

wants to merge 6 commits into from

Conversation

agatatalita
Copy link
Member

No description provided.

@agatatalita agatatalita requested a review from mrkvon April 18, 2018 13:26
@agatatalita
Copy link
Member Author

There might be some minor things to correct like:

  • binding variables in AQL queries
  • exporting some constant values

I just didn't feel like playing with making it perfect so much before any refactorization/DRYing.

Copy link
Member

@mrkvon mrkvon left a comment

Choose a reason for hiding this comment

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

Added some comments. Will do more review.

LET us = (FOR u IN users FILTER u.username == @creatorUsername RETURN u)
// create the ditTag (if dit, tag and creator exist)
LET ${ditType}Tag = (FOR d IN ds FOR t IN ts FOR u IN us FILTER u._id == d.creator
INSERT MERGE({ _from: d._id, _to: t._id, creator: u._id }, @ditTag) IN ${ditType}Tags RETURN KEEP(NEW, 'created'))[0] || { }
Copy link
Member

Choose a reason for hiding this comment

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

name of the collection can (and should) be provided with placeholder @@ditTypeTags (two @ refer to collection name)

and then const params = { '@ditTypeTags': ditType + 'Tags' }

also above for ${ditType}.
This won't work for variable names, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote in the comment that it is not done yet.

e.code = 404;
e.missing = [];

[`${ditType}`, 'tag', 'creator'].forEach((potentialMissing) => {
Copy link
Member

Choose a reason for hiding this comment

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

`${}` is not necessary here. (also on line 60)

}
]
},

Copy link
Member

Choose a reason for hiding this comment

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

votes.to should include 'challenges' here in this file.
(i can't comment directly there)


module.exports = {
get: {
withMyTags: route(['query.filter.withMyTags']),
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 a reason to keep these as separate code from goto.ideas?
I imagine that these are and will stay very similar (deciding based on query string).


const validate = require('./validate-by-schema');

const del = validate('deleteChallengeTag');
Copy link
Member

Choose a reason for hiding this comment

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

Will json-schemata for these be getting different from other dit-tags in the future? Is there a reason to keep them separate?


module.exports = {
get: validate('getChallenge'),
getChallengesCommentedBy: validate('getChallengesCommentedBy'),
Copy link
Member

Choose a reason for hiding this comment

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

Again, would it be perhaps worth having these generalized as getDitsCommentedBy? These schemata seem to not be ditType specific.

properties: {
title,
detail,
ditType
Copy link
Member

Choose a reason for hiding this comment

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

how does this value appear in the req.body? It's new to me.

static async random(ditType, { limit }) {
const ditCollection = ditType + 's';
const query = `
FOR ${ditType} IN @@ditCollection
Copy link
Member

Choose a reason for hiding this comment

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

is it necessary to make the query (and other queries) variable like this?
Perhaps it would be more straightforward and secure to use dit instead of ${ditType} in this query?

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