Skip to content

Consider: simplified update_vote #107

@stiffneckjim

Description

@stiffneckjim

Consider:

 def update_vote(self, vote_type):
        vote_upwards = 1 if vote_type > 0 else -1
        same_direction = -1 if vote_upwards == self.track_vote else 1
        self.track_vote += vote_upwards * same_direction
        assert -1 <= self.track_vote <= 1
        self.save()

Originally posted by @sfkleach in #106 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions