'Create a \'vote\' event for event-collector
vote: An r2.models.vote Vote object'

@squelch_exceptions
@sampled('events_collector_vote_sample_rate')
def vote_event(self, vote):

    def get_vote_direction_name(vote):
        if vote.is_upvote:
            return 'up'
        elif vote.is_downvote:
            return 'down'
        else:
            return 'clear'
    event = Event(topic='vote_server', event_type='server_vote', time=vote.date, data=vote.event_data['context'], obfuscated_data=vote.event_data['sensitive'])
    event.add('vote_direction', get_vote_direction_name(vote))
    if vote.previous_vote:
        event.add('prev_vote_direction', get_vote_direction_name(vote.previous_vote))
        event.add('prev_vote_ts', to_epoch_milliseconds(vote.previous_vote.date))
    if vote.is_automatic_initial_vote:
        event.add('auto_self_vote', True)
    for (name, value) in vote.effects.serializable_data.iteritems():
        if (name == 'notes'):
            name = 'details_text'
        event.add(name, value)
    event.add('process_notes', ',    '.join(vote.effects.note_codes))
    event.add_subreddit_fields(vote.thing.subreddit_slow)
    event.add_target_fields(vote.thing)
    rank = vote.data.get('rank')
    if rank:
        event.add('target_rank', rank)
    self.save_event(event)
