package ru.yandex.webmaster3.storage.searchurl.download;

import ru.yandex.webmaster3.core.sitestructure.SearchUrlStatusEnum;
import ru.yandex.webmaster3.storage.searchurl.samples.data.SearchUrlEventType;
import ru.yandex.webmaster3.storage.searchurl.samples.data.UrlStatusInfo;

/**
 * Created by Oleg Bazdyrev on 13/05/2021.
 * TODO надо подумать, куда бы все перенести
 */
public class SearchurlReportUtil {

    public static String toStringYesNo(Boolean isExist) {
        return isExist ? "YES" : "NO";
    }

    public static String getTarget(UrlStatusInfo statusInfo) {
        if (statusInfo == null) {
            return "";
        }
        if (statusInfo.getStatus().equals(SearchUrlStatusEnum.INDEXED_NOTSEARCHABLE) || statusInfo.getStatus().equals(SearchUrlStatusEnum.SEMIDUP)) {
            return statusInfo.getBeautyUrl();
        }
        String target = (statusInfo.getRedirectTarget() != null) ? statusInfo.getRedirectTarget() : statusInfo.getRelCanonicalTarget();
        if (target == null) {
            return "";
        }
        return target;
    }

    public static String getEventView(SearchUrlEventType eventType) {
        switch (eventType) {
            case GONE:
                return "DELETE";
            case NEW:
                return "ADD";
            default:
                return "";
        }
    }

}
