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

Issue 643 #770

Merged
merged 6 commits into from
Oct 18, 2015
Merged

Issue 643 #770

merged 6 commits into from
Oct 18, 2015

Conversation

Martii
Copy link
Member

@Martii Martii commented Oct 17, 2015

Read specific commit notes since this was at least a two six part'er.

Applies to #643 and leads into #641


Tested on dev and local pro


A screenshot, perhaps more:

  • issue-643flaggedscriptlist opt
  • issue-643flaggedscript opt

Martii added 2 commits October 15, 2015 16:37
* Base working concept
* Eventual showing of the reason in respective views... currently set to a horizontal ellipsis if absent... see additional notes below

Applies to OpenUserJS#643 and OpenUserJS#641

NOTES:
* Test with QSP `?flagged=true` for lists and Admin or better privileges on script homepage and user homepage with logged in and logged out... there are at least 6 routes *(4 with QSP and 2 without but all elevated to Admin+)* needed to test against
* If for some reason some user is flagged but there aren't any actual flags it will show up as no user and no reason e.g. Flagged column will be empty for those mustache opts
* Using series in some of the *async* related calls to hopefully ensure natural ordered flags
* **NOT COMPACTED** for clarity as well as for strict *async* usage
* One bug fix in a view with colspan
* One restoration in `.../modelParser.js`
* Some class changes in a view

TODO: *(mitigation)*
* Needs reason attached to flagging route ... separate issue to be created and milestoned near OpenUserJS#485 and OpenUserJS#262 and similarly done in OpenUserJS#513
* Standardize on `flagList` since `flagged` is already in use
* Some compaction of the code ... backed out a few changes in prior commit... added a master asynchronous function to the flag library
* One bug fix with `modelParser` to acccomodate prior commit reversion

**NOTES**:
* This should be functionally equivalent to the last commit feature wise and a lot easier to maintain. An example of this is the dynamic field name change in this commit... easily changeable in case someone doesn't like that name but should be okay for now.

Applies to OpenUserJS#643 and indirectly OpenUserJS#641
@Martii Martii added bug You've guessed it... this means a bug is reported. UI Pertains inclusively to the User Interface. PR READY This is used to indicate that a pull request (PR) is ready for evaluation. CODE Some other Code related issue and it should clearly describe what it is affecting in a comment. feature Something we don't already have implemented to the best of knowledge but would like to see. labels Oct 17, 2015
@Martii
Copy link
Member Author

Martii commented Oct 17, 2015

@sizzlemctwizzle
bump

@Martii
Copy link
Member Author

Martii commented Oct 17, 2015

Misc notes (before merging... questions may change):

  • Consider renaming setFlaggedListInModel to parseFlag...IntoModel and move into .../modelParser.js ? e.g. is there a better name and a better location?
  • Include all model requires where ever this lands (distribution in the project tree) so if someone uses 'Comment' down the line it won't bomb since right now only 'User', 'Flag' and 'Script' models are in use ? (may be moot here)
  • More STYLEGUIDE.md conformance in affected functions ? *(mainly newlines I think with perhaps some forward to ES6 compliance ... ./controllers/user.js is huge so needs lots more testing)* ... (perhaps do later but constantly)
  • ...

if (aErr) {
aNext();
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

MITIGATION: Test why this error fall through is the only one (for express)... I am guessing if we (ever) have an error in the changed views ("elsewhere") we're going to 500 and not fail gracefully.

Copy link
Member

Choose a reason for hiding this comment

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

asyncComplete should always test for an error and handle it (at the very least a 500 page). If we can catch an error earlier on then great, but this is really the last line of defense. It would be nice if we could find a way to abstract this function and put it in libs/helpers.js since I hate seeing the same logic repeated, but I realize the difficulty of doing this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Kind of figured that with the missing aNext() and it raised an eyebrow yesterday in my background thinking... I think I'll do that in a single PR with some cleanup just on ./controllers/user.js... I read elsewhere that ES6 is going to need undefined for certain functions instead of null (or worse some other huge object in a bug) so that is why I have been splitting out the aNext() and return statements... also it makes more sense not to return something that isn't there and could change down the line.

Just a misc note too node 4.x went LTS (Long Term Support) according to their site e.g. 5.x is around some corner.

@Martii
Copy link
Member Author

Martii commented Oct 17, 2015

Need some input from those questions above before anyone can merge.

Additional note...we could eventually show Mods just the reason, but not the user/author, so they can make an informed decision as to flag a critically flagged script/user but I left that alone for this PR.

@Martii Martii added the question A question has been encountered by anyone and has remained unanswered until cleared. label Oct 17, 2015
@@ -148,3 +150,51 @@ exports.unflag = function (aModel, aContent, aUser, aCallback) {
}
});
};

exports.setFlaggedListInModel = function (aModelName, aOptions, aCallback) {
Copy link
Member

Choose a reason for hiding this comment

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

This is definitely the wrong module for this function. This module is supposed to be completely devoid of any front-end view logic (notice how "aOptions" or "options" are mentioned nowhere else in this file). This module defines the logic for how flagging is handled.

Copy link
Member Author

Choose a reason for hiding this comment

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

So where should it go?... I don't have a clue since this function is a "one of a kind new" thing AFAIK

Copy link
Member

Choose a reason for hiding this comment

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

Answered in my comment below.

@sizzlemctwizzle
Copy link
Member

Consider renaming

Yes, as my line comment says, the code should be moved. Create a flag.js controller. Remove has a model, lib, and controller. Flag and vote should be structured like this as well. So you might as well start the flag controller for this.

Include all model requires where ever this lands

There is code for this already. Vote, Flag, and Remove are all actions that I implemented in that order. They are very similar so the implementations got more well thought out as I went (with Remove being the best version). I suspect that's why you're having a problem finding the right place to put the new flag function, since it's controller logic and Flag doesn't currently have a controller.

More STYLEGUIDE.md conformance in affected functions

Nice to have, but lower priority.

@Martii Martii removed the PR READY This is used to indicate that a pull request (PR) is ready for evaluation. label Oct 18, 2015
@Martii
Copy link
Member Author

Martii commented Oct 18, 2015

Create a flag.js controller.

Done locally... need to link it in though.

Remove has a model, lib, and controller.

That appears Greek to me at the moment... what?

Flag and vote should be structured like this as well.

Did you want me to create a base vote.js controller too?

There is code for this already. Vote, Flag, and Remove are all actions that I implemented in that order. They are very similar so the implementations got more well thought out as I went (with Remove being the best version). I suspect that's why you're having a problem finding the right place to put the new flag function, since it's controller logic and Flag doesn't currently have a controller.

I'll have to wait and see what you say on this part once I create the controller(s).

Thanks for the feedback... more to tinker with to get this reworking. Will buzz you later.

* Created `flag.js` controller as per sizzle and moved the export there
* Created `vote.js` controller base
* Move/remove last commit stuff out that was added in.
* Renamed `setFlaggedListInModel` to `setFlaggedListToModel` ... this still could use some advice on exact name that is wanted for the identifier.
* NOTE'd a possible extra dir traversal that shouldn't be needed as compared to below requires... this is beyond this PR and will retest/cleanup in another unrelated commit so just noting it

Applies to OpenUserJS#643
@Martii
Copy link
Member Author

Martii commented Oct 18, 2015

@sizzlemctwizzle
Buzz, buzz, buzz! :) Now if you want me to rename the function name please give me an exact identifier please otherwise I'll just go with that function name. If I were to include the base controller in as flag we might have an issue as that identifier could be taken elsewhere... so I just imported the jsm function itself.

I still don't have a clue what you meant by "Remove has a model, lib, and controller.".

Did create a vote.js controller just as a placeholder to avoid future confusion perhaps. Not linked in anywhere though.

Noticed a weird require too and notated it... probably why it has newlines around it... seems like something I would have done early on but not sure.

Now what is the correct next step? Fully retested on dev at current PR tip since this is super fresh and that was a simple move.

@sizzlemctwizzle
Copy link
Member

I still don't have a clue what you meant by "Remove has a model, lib, and controller.".

Remove action:
Model: models/remove.js
Lib: libs/remove.js
Controller: controllers/remove.js

Flag action:
Model: models/flag.js
Lib: libs/flag.js
Controller: all flag controller logic is currently spread out amongst multiple controllers, but I'd like you to create a controllers/flag.js file and put your function in it (the current name is fine)

Vote action:
Model: models/vote.js
Lib & Controller: all logic for voting embedded and spread out amongst multiple controllers, but you don't need to create any files until you have something to put in them

@Martii
Copy link
Member Author

Martii commented Oct 18, 2015

Oh durrr... I was taking "Remove" as something you wanted me to do... not the controller itself. Sawwy.

@Martii
Copy link
Member Author

Martii commented Oct 18, 2015

So did you want a different identifier name for this function e.g. signature or do you think this is PR READY?

@sizzlemctwizzle
Copy link
Member

How about getFlaggedListForContent?

@Martii
Copy link
Member Author

Martii commented Oct 18, 2015

but you don't need to create any files until you have something to put in them

Disagree due to the confusion. If I come back to a similar case where I can't figure out where to put it I may not recall this conversation.

getFlaggedListForContent

I'm game for that... I thought about calling it sizzle since I had no clue on naming conventions and especially now since it's in a new controller.... k uno momento for the identifier change. I tossed back and forth between Model and Content during this anyhow... just didn't know what was expected. Thanks.

@sizzlemctwizzle
Copy link
Member

If I come back to a similar case where I can't figure out where to put it I may not recall this conversation.

Good point. I actually found myself unable to remember which actions lacked which files.

I tossed back and forth between Model and Content during this anyhow

If I see Model in the name it makes me think I'm going to get (mongoose) model objects back from the function, when this function really adds more content via aOptions.

* Using this to be more consistent with other contributors and upon the advice of Lord Sizzle! :)

Applies to OpenUserJS#643
@Martii
Copy link
Member Author

Martii commented Oct 18, 2015

Okay... done and retested (logged out, logged in with anyone, logged in with Admin) ... anything else before you test it with PR READY?

I've done a shiz load of testing on this function (over 50 hours) especially when I compacted it so it should be good to go. Thanks for your patience with me and "hand holding" at my request... I'm still not clear on MVC and all the local book stores have nothing on this style of coding... search results just aren't doing it... may have to pay a visit to a University to get a hold of a book! :)

@Martii Martii added needs testing Anyone can add this but it is primarily there for the Assignee indicating that Testers are wanted. and removed question A question has been encountered by anyone and has remained unanswered until cleared. labels Oct 18, 2015
* As described earlier placeholder so anyone knows where to start to put things without a search

NOTE:
Specific to OpenUserJS#770 (comment)

Applies indirectly to OpenUserJS#643
@Martii Martii added the PR READY This is used to indicate that a pull request (PR) is ready for evaluation. label Oct 18, 2015
* This is somewhat flexible when needed but will assist in directing contributions. This is mostly the current pattern.
* During a cleanup phase will probably match this general code styling in the other controllers

Applies indirectly to OpenUserJS#643
@Martii Martii removed the needs testing Anyone can add this but it is primarily there for the Assignee indicating that Testers are wanted. label Oct 18, 2015
@Martii
Copy link
Member Author

Martii commented Oct 18, 2015

Auto-merging soon as retests and pouring over the code for a few more hours seems good to go.

Martii added a commit that referenced this pull request Oct 18, 2015
@Martii Martii merged commit 89e2321 into OpenUserJS:master Oct 18, 2015
@Martii Martii deleted the Issue-643 branch October 18, 2015 19:28
@Martii Martii removed the PR READY This is used to indicate that a pull request (PR) is ready for evaluation. label Oct 18, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug You've guessed it... this means a bug is reported. CODE Some other Code related issue and it should clearly describe what it is affecting in a comment. feature Something we don't already have implemented to the best of knowledge but would like to see. UI Pertains inclusively to the User Interface.
Development

Successfully merging this pull request may close these issues.

2 participants