package com.tzld.piaoquan.ad.engine.service.score.deprecated;


import com.tzld.piaoquan.ad.engine.commons.score.BaseLRModelScorer;
import com.tzld.piaoquan.ad.engine.commons.score.ScoreParam;
import com.tzld.piaoquan.ad.engine.commons.score.ScorerConfigInfo;
import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
import com.tzld.piaoquan.recommend.feature.domain.ad.base.UserAdFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;
import java.util.List;


//@Service
public class Share0MergeBreakScorer extends BaseLRModelScorer {

    private final static Logger log = LoggerFactory.getLogger(Share0MergeBreakScorer.class);


    public Share0MergeBreakScorer(ScorerConfigInfo configInfo) {
        super(configInfo);
    }


    @Override
    public List<AdRankItem> scoring(final ScoreParam param,
                                    final UserAdFeature userFeature,
                                    final List<AdRankItem> rankItems) {

        for (AdRankItem item : rankItems) {
           try {
               item.setScore(item.getCtr()*item.getCvr()/(item.getStr()*item.getRos()*0.2));
           }catch (Exception e){
               item.setScore(0);
           }
        }
        Collections.sort(rankItems);
        return rankItems;
    }

    @Override
    public void loadModel() {
        // nothing;
    }
}