-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revised public fields, wrote more exhaustive specs
- Loading branch information
Showing
9 changed files
with
665 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,8 @@ def graphql_type_description | |
|
||
end | ||
|
||
def public_created_at | ||
self.created_at.change(min: 0) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
class Vote < ActsAsVotable::Vote | ||
|
||
include Graphqlable | ||
|
||
def self.public_for_api | ||
joins("FULL OUTER JOIN debates ON votable_type = 'Debate' AND votable_id = debates.id"). | ||
joins("FULL OUTER JOIN proposals ON votable_type = 'Proposal' AND votable_id = proposals.id"). | ||
joins("FULL OUTER JOIN comments ON votable_type = 'Comment' AND votable_id = comments.id"). | ||
where("votable_type = 'Proposal' AND proposals.hidden_at IS NULL OR votable_type = 'Debate' AND debates.hidden_at IS NULL OR votable_type = 'Comment' AND comments.hidden_at IS NULL") | ||
end | ||
|
||
def public_timestamp | ||
self.created_at.change(min: 0) | ||
where("(votable_type = 'Proposal' AND proposals.hidden_at IS NULL) OR \ | ||
(votable_type = 'Debate' AND debates.hidden_at IS NULL) OR \ | ||
( \ | ||
(votable_type = 'Comment' AND comments.hidden_at IS NULL) AND \ | ||
( \ | ||
(comments.commentable_type = 'Proposal' AND (comments.commentable_id IN (SELECT id FROM proposals WHERE hidden_at IS NULL GROUP BY id))) OR \ | ||
(comments.commentable_type = 'Debate' AND (comments.commentable_id IN (SELECT id FROM debates WHERE hidden_at IS NULL GROUP BY id))) \ | ||
) \ | ||
)") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.