<commit_before>package mingzuozhibi.action;

import mingzuozhibi.persist.disc.Disc;
import mingzuozhibi.persist.disc.Sakura;
import mingzuozhibi.persist.disc.Sakura.ViewType;
import mingzuozhibi.support.JsonArg;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

import static mingzuozhibi.action.DiscController.buildSet;
import static mingzuozhibi.persist.disc.Sakura.ViewType.PrivateList;

@RestController
public class SakuraController extends BaseController {

    public final static String DISC_COLUMNS = "id,thisRank,prevRank,totalPt,title,titlePc,titleMo";
    public final static String DISC_COLUMNS_ADMIN = "id,asin,thisRank,surplusDays,title,titlePc,titleMo";

    public static Set<String> DISC_COLUMNS_SET = buildSet(DISC_COLUMNS);
    public static Set<String> DISC_COLUMNS_ADMIN_SET = buildSet(DISC_COLUMNS_ADMIN);

    @Transactional
    @GetMapping(value = "/api/sakuras", produces = MEDIA_TYPE)
    public String findAll(@RequestParam(name = "public", defaultValue = "true") boolean isPublic) {
        @SuppressWarnings("unchecked")
        List<Sakura> sakuras = dao.query(session -> {
            Criteria criteria = session.createCriteria(Sakura.class);
            if (isPublic) {
                criteria.add(Restrictions.ne("viewType", PrivateList));
                criteria.add(Restrictions.eq("enabled", true));
            }
            return criteria.list();
        });

        JSONArray result = new JSONArray();

        sakuras.forEach(sakura -> {
            result.put(sakura.toJSON());
        });

        if (LOGGER.isDebugEnabled()) {
            debugRequest("[获取多个列表成功][列表数量={}]", sakuras.size());
        }
        return objectResult(result);
    }

    @Transactional
    @GetMapping(value = "/api/sakuras/key/{key}", produces = MEDIA_TYPE)<commit_msg>style(sakura): Adjust the string order<commit_after>package mingzuozhibi.action;

import mingzuozhibi.persist.disc.Disc;
import mingzuozhibi.persist.disc.Sakura;
import mingzuozhibi.persist.disc.Sakura.ViewType;
import mingzuozhibi.support.JsonArg;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

import static mingzuozhibi.action.DiscController.buildSet;
import static mingzuozhibi.persist.disc.Sakura.ViewType.PrivateList;

@RestController
public class SakuraController extends BaseController {

    public final static String DISC_COLUMNS = "id,thisRank,prevRank,totalPt,title,titlePc,titleMo";
    public final static String DISC_COLUMNS_ADMIN = "id,asin,thisRank,title,titlePc,titleMo,surplusDays";

    public static Set<String> DISC_COLUMNS_SET = buildSet(DISC_COLUMNS);
    public static Set<String> DISC_COLUMNS_ADMIN_SET = buildSet(DISC_COLUMNS_ADMIN);

    @Transactional
    @GetMapping(value = "/api/sakuras", produces = MEDIA_TYPE)
    public String findAll(@RequestParam(name = "public", defaultValue = "true") boolean isPublic) {
        @SuppressWarnings("unchecked")
        List<Sakura> sakuras = dao.query(session -> {
            Criteria criteria = session.createCriteria(Sakura.class);
            if (isPublic) {
                criteria.add(Restrictions.ne("viewType", PrivateList));
                criteria.add(Restrictions.eq("enabled", true));
            }
            return criteria.list();
        });

        JSONArray result = new JSONArray();

        sakuras.forEach(sakura -> {
            result.put(sakura.toJSON());
        });

        if (LOGGER.isDebugEnabled()) {
            debugRequest("[获取多个列表成功][列表数量={}]", sakuras.size());
        }
        return objectResult(result);
    }

    @Transactional
    @GetMapping(value = "/api/sakuras/key/{key}", produces = MEDIA_TYPE)
{'fraction_non_alphanumeric': 0.11263282172373082, 'fraction_numerical': 0.0, 'mean_word_length': 3.9198606271777003, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '412927', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1316, 'n_words': 217}