DataMascara / cisc3140-su19-project

https://bc-app-class.herokuapp.com/login/
2 stars 5 forks source link

Database: Error in all_votes_by method #36

Closed derickfan closed 5 years ago

derickfan commented 5 years ago

When I try to get all for the votes for a certain username I get an error saying 'userId' is an unknown column Screen Shot 2019-08-12 at 12 10 23 PM Screen Shot 2019-08-12 at 12 10 41 PM Also is it possible to simultaneously get the upvotes and downvotes rather than having to first get the upvotes then the downvotes?

chalshaff12 commented 5 years ago

The issue should be fixed.

In terms of getting both up and downvotes, I can create a new method for that (which is annoying) or I can edit the method to include one more parameter. It would look like this: def all_votes_by(username, column_name, data_value, type, operation) where operation would be either '=' or '<>' ex.

# get all upvotes def all_votes_by("chalshaff12", "vote", 1, "post", '=')

# get all downvotes def all_votes_by("chalshaff12", "vote", -1, "post", '=')

# get all saved def all_votes_by("chalshaff12", "isSaved", 1, "post", '=')

# get all up and downvotes together def all_votes_by("chalshaff12", "vote", 0, "post", '<>')

Let me know if you want me to implement that and do it asap

derickfan commented 5 years ago

Yea that would be awesome. Thanks

chalshaff12 commented 5 years ago

Updated the function, let me know if there are any more issues with it