예제 #1
0
Status CrowdSoundAdminImpl::GetDBStats(ServerContext* context, const GetDBStatsRequest* request, GetDBStatsResponse* response) {
    skrillex::ResultSet<skrillex::Song>   songs;
    skrillex::ResultSet<skrillex::Artist> artists;
    skrillex::ResultSet<skrillex::Genre>  genres;

    skrillex::Status s = server_->db_->getSongs(songs);
    if (s != skrillex::Status::OK()) {
        return Status(StatusCode::INTERNAL, s.message());
    }

    s = server_->db_->getArtists(artists);
    if (s != skrillex::Status::OK()) {
        return Status(StatusCode::INTERNAL, s.message());
    }

    s = server_->db_->getGenres(genres);
    if (s != skrillex::Status::OK()) {
        return Status(StatusCode::INTERNAL, s.message());
    }

    response->set_num_songs(songs.size());
    response->set_num_artists(artists.size());
    response->set_num_genres(genres.size());

    return Status::OK;
}
예제 #2
0
Status CrowdSoundAdminImpl::apply(const SetSettingRequest* request, string& val) {
    if (request->value_case() != SetSettingRequest::ValueCase::kStrVal) {
        return Status(StatusCode::INVALID_ARGUMENT, "invalid type for key");
    }

    val = request->str_val();

    return Status::OK;
}
예제 #3
0
	Status PingMe(ServerContext* context, const User* request, PingInfo* response) override {
		if (request->id().compare("12983479238947"))
		{
			response->set_time(1000);
		}
		else
			response->set_time(0);

		return Status(StatusCode::PERMISSION_DENIED, "whaaat");
	}
예제 #4
0
Status CrowdSoundAdminImpl::SetSetting(ServerContext* context, const SetSettingRequest* request, SetSettingResponse* response) {
    lock_guard<mutex> lock(server_->settings_guard_);

    // Why no switch supper :( or any nice way to do this
    if (request->key() == "filter_buffered")            { return apply(request, server_->skrillex_read_options_.filter_buffered); }
    else if (request->key() == "inactivity_threshold")  { return apply(request, server_->skrillex_read_options_.inactivity_threshold); }
    else if (request->key() == "result_limit")          { return apply(request, server_->skrillex_read_options_.result_limit); }

    // Query Options
    else if (request->key() == "session_name")          { return apply(request, server_->session_name_); }
    else if (request->key() == "queue_size")            { return apply(request, server_->queue_size_); }
    else if (request->key() == "trending_artists_size") { return apply(request, server_->trending_artists_size_); }
    else if (request->key() == "skip_threshold")        { return apply(request, server_->skip_threshold_); }

    // Algorithm settings
    else if (request->key() == "count_weight")          { return apply(request, server_->algo_settings_.m_countWeight); }
    else if (request->key() == "vote_weight")           { return apply(request, (int&)server_->algo_settings_.m_voteWeight); }
    else if (request->key() == "genre_weight")          { return apply(request, server_->algo_settings_.m_genreWeight); }
    else if (request->key() == "artist_weight")         { return apply(request, server_->algo_settings_.m_artistWeight); }
    else if (request->key() == "played_again_mult")     { return apply(request, server_->algo_settings_.m_playedAgainMultipler); }
    else if (request->key() == "min_repeat_window")     { return apply(request, server_->algo_settings_.m_minsBeforeCanPlayAgain); }

    return Status(StatusCode::NOT_FOUND, "key not found");
}
예제 #5
0
Status CrowdSoundAdminImpl::SkipStatus(ServerContext* context, const SkipStatusRequest* request, SkipStatusResponse* resp) {
    int votesToSkip = 0;
    int totalUsers = 0;

    {
        lock_guard<recursive_mutex> lock(server_->skip_guard_);

        votesToSkip = server_->skip_voters_.size();
        skrillex::Status status = server_->db_->getSessionUserCount(totalUsers, server_->skrillex_read_options_);
        if (status != skrillex::Status::OK()) {
            return Status(StatusCode::INTERNAL, status.message());
        }
    }

    resp->set_votes_to_skip(votesToSkip);
    resp->set_total_users(totalUsers);

    {
        lock_guard<mutex> lock(server_->settings_guard_);
        resp->set_threshold(server_->skip_threshold_);
    }

    return Status::OK;
}