-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
There might be some minor things to correct like:
I just didn't feel like playing with making it perfect so much before any refactorization/DRYing. |
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.
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] || { } |
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.
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.
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 wrote in the comment that it is not done yet.
e.code = 404; | ||
e.missing = []; | ||
|
||
[`${ditType}`, 'tag', 'creator'].forEach((potentialMissing) => { |
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 not necessary here. (also on line 60)
} | ||
] | ||
}, | ||
|
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.
votes.to
should include 'challenges'
here in this file.
(i can't comment directly there)
|
||
module.exports = { | ||
get: { | ||
withMyTags: route(['query.filter.withMyTags']), |
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 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'); |
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.
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'), |
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.
Again, would it be perhaps worth having these generalized as getDitsCommentedBy
? These schemata seem to not be ditType specific.
properties: { | ||
title, | ||
detail, | ||
ditType |
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.
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 |
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 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?
No description provided.