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

Code Cleanup #369

Closed
wants to merge 6 commits into from
Closed

Conversation

ThePletch
Copy link
Contributor

Work in progress - cleaning things up, using ActiveRecord query methods over array manipulation, moving complex logic out to helper methods when possible.

@ThePletch
Copy link
Contributor Author

I've been trying to rebase this off the main repo's master branch, but there's an incredibly annoying problem where you have both a vendor/assets/bower_components/jquery and a vendor/assets/bower_components/jQuery. They're two separate things to git, but OSX's case-insensitive filesystem treats them as being the same folder, so I can't remove changes to it from the repo.

[Kim]: Steve, thank you for trouble shooting this issue, which I've had as well but did not know the "why". the good news is that I'm working on a branch in which jQuery is eliminated in favor of just native Angular's built-in jQuery lite and should fix the issue.

@ThePletch This issue should now be fixed with pr #373.

@kimardenmiller
Copy link
Contributor

Wow, Steve. Very interesting.

# def self_and_descendants # dupe of all_related_proposals
# [self.root, self.root.descendants].flatten
# end

def related_proposals(related_sort_by = 'Most Votes')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not a fan of this method, mostly because switching the sorting function off a string like this is a bad code smell. These functions are similar enough that this method could be heavily simplified or abstracted. In-place sorting should also be avoided if possible, especially in a situation like this where replacing sort! with sort wouldn't change the function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Again, no worries if you wanted to change the API here. If you did, note that the UI is currently broken here per issue #311. Nothing serious, I think just a seam library that changed something.

@ThePletch
Copy link
Contributor Author

Also, could you go over your data model a little more? I'm not clear on why the proposals are organized in a full tree structure. All the tree traversal is preventing you from doing a lot of data manipulation on the database side, which would be miles faster.

if response.comment is null
responseMessage = "Your vote was recorded without a comment"
else
responseMessage = "Your vote was created with the comment: ""#{response.comment}"""
Copy link
Contributor

Choose a reason for hiding this comment

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

You will need to escape those quotes, \"#{response.comment}\"

@kimardenmiller
Copy link
Contributor

The model (application) uses trees of related proposals, where related means forked from each other.

We care about these trees because:

  • Voters can have only one vote in each tree.
  • Further voting or forking in a tree results user's votes getting "moved".
  • The index page shows only the top-voted proposal for each tree.

@ThePletch
Copy link
Contributor Author

Would you object to removing commented-out code, since you can just bring back old code from the git history if necessary?

@ThePletch
Copy link
Contributor Author

I think that about finishes things for me unless a spec fails or you'd like me to clean up commented-out/nulled-out code (there was a line of code that was if Rails.env.development? && 1 == 2 that piqued my interest).

@kimardenmiller
Copy link
Contributor

Awesome, Steve. Let me take a look this weekend!

/k

On Fri, Jul 3, 2015 at 1:20 PM, Steve Pletcher notifications@github.com
wrote:

I think that about finishes things for me unless a spec fails or you'd like me to clean up commented-out/nulled-out code (there was a line of code that was if Rails.env.development? && 1 == 2 that piqued my interest).

Reply to this email directly or view it on GitHub:
#369 (comment)

rescue ArgumentError
pp "WARNING: Could not use google service to find hubs"
rescue ArgumentError => e
Rails.logger.error "WARNING: Could not use google service to find hubs. Error: #{e.message}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should probably be Rails.logger.warn now that I think about it.

@kimardenmiller
Copy link
Contributor

@ThePletch, was this branch testing and working for you? Some of the changes, e.g. in application controller, seem to delete necessary things. As is, I'm not getting the branch to actually spin up:
image

@kimardenmiller
Copy link
Contributor

Commits contained in PR #381, where merge conflicts have been solved and code comments have been deleted.

kimardenmiller added a commit that referenced this pull request Aug 18, 2015
Code Clean Up Reviewed, Ruby comments removed, Rebased & Resolved Merge Conflicts for PR #369
@kimardenmiller
Copy link
Contributor

Hi @ThePletch, any thoughts on this error?

image

image

That GL-CjQu .... hub ID is part of the Google Places feature, so a normal part of the API.

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