<commit_before><?php
    /**
     * @class  resourceModel
     * @author zero (<EMAIL>)
     * @brief  resource model class
     **/

    class resourceModel extends resource {

        function init() {
        }

        function getPackageList($module_srl, $status = null, $category_srl = null, $member_srl = null) {
            $args->module_srl = $module_srl;

            if(!is_null($status) && in_array($status, array('accepted','reservation','waiting'))) $args->status = $status;
            else $args->idx_status = 'a';

            if(!is_null($category_srl)) $args->category_srl = $category_srl;
            else $args->idx_category_srl = 0;

            if(!is_null($member_srl)) $args->member_srl = $member_srl;

            $output = executeQueryArray('resource.getPackageList', $args);

            return $output;
        }

        function getPackage($module_srl, $package_srl, $member_srl = null) {
            $args->module_srl = $module_srl;
            $args->package_srl = $package_srl;

            if(is_null($member_srl)) $args->member_srl = $member_srl;
            $output = executeQuery('resource.getPackage', $args);
            return $output->data;
        }

        function getItem($module_srl, $package_srl, $item_srl) {
            $oFileModel = &getModel('file');
            $args->module_srl = $module_srl;
            $args->package_srl = $package_srl;
            $args->item_srl = $item_srl;

            $output = executeQuery('resource.getItem', $args);
            if(!$output->toBool() || !$output->data) return null;
            $item = $output->data;
            $item->download_url = getFullUrl().$oFileModel->getDownloadUrl($val->file_srl, $val->sid);
            return $item;
        }

        function getItems($module_srl, $package_srl) {
            $oFileModel = &getModel('file');

            $args->module_srl = $module_srl;
            $args->package_srl = $package_srl;

            $output = executeQueryArray('resource.getItems', $args);
            if(!$output->data) return array();
            foreach($output->data as $key => $val) {
                if($val->voter>0) $val->star = (int)($val->voted/$val->voter);
                else $val->star = 0;
                $output->data[$key]->download_url = getFullUrl().$oFileModel->getDownloadUrl($val->file_srl, $val->sid);
            }

            return $output->data;
        }

        function getLatestItemList($module_srl, $category_srl = null, $childs = null, $member_srl = null, $search_keyword = null, $order_target = 'package.update_order', $order_type = 'asc') {
            $oFileModel = &getModel('file');

            $args->module_srl = $module_srl;

            if(!is_null($childs) && preg_match('/^([0-9])([0-9,]+)([0-9])$/', $childs)) $args->category_srl = $childs;
            else if(!is_null($category_srl)) $args->category_srl = $category_srl;
            else $args->idx_category_srl = 0;

            if(!is_null($member_srl)) $args->member_srl = $member_srl;

            if($search_keyword) {
                $tr = explode(' ',$search_keyword);
                for($i=0,$c=count($tr);$i<$c;$i++) {
                    if(trim($tr[$i])) $t[] = trim($tr[$i]);
                }
                if(count($t)) $args->search_keyword = implode('%', $t);
            }

            $args->order_type = $order_type;
            if($order_target == 'latest') $args->sort_index = 'package.last_update';
            elseif($order_target == 'popular') $args->sort_index = 'package.voted';
            else {
                $args->sort_index = 'package.list_order';
                if($args->order_type=='desc') $args->order_type = 'asc';
                else $args->order_type = 'desc';
            }
            $output = executeQueryArray('resource.getLatestItemList', $args);
            if($output->data) {
                foreach($output->data as $key => $val) {<commit_msg>신규등록의 정렬 순서 오류 수정<commit_after><?php
    /**
     * @class  resourceModel
     * @author zero (<EMAIL>)
     * @brief  resource model class
     **/

    class resourceModel extends resource {

        function init() {
        }

        function getPackageList($module_srl, $status = null, $category_srl = null, $member_srl = null) {
            $args->module_srl = $module_srl;

            if(!is_null($status) && in_array($status, array('accepted','reservation','waiting'))) $args->status = $status;
            else $args->idx_status = 'a';

            if(!is_null($category_srl)) $args->category_srl = $category_srl;
            else $args->idx_category_srl = 0;

            if(!is_null($member_srl)) $args->member_srl = $member_srl;

            $output = executeQueryArray('resource.getPackageList', $args);

            return $output;
        }

        function getPackage($module_srl, $package_srl, $member_srl = null) {
            $args->module_srl = $module_srl;
            $args->package_srl = $package_srl;

            if(is_null($member_srl)) $args->member_srl = $member_srl;
            $output = executeQuery('resource.getPackage', $args);
            return $output->data;
        }

        function getItem($module_srl, $package_srl, $item_srl) {
            $oFileModel = &getModel('file');
            $args->module_srl = $module_srl;
            $args->package_srl = $package_srl;
            $args->item_srl = $item_srl;

            $output = executeQuery('resource.getItem', $args);
            if(!$output->toBool() || !$output->data) return null;
            $item = $output->data;
            $item->download_url = getFullUrl().$oFileModel->getDownloadUrl($val->file_srl, $val->sid);
            return $item;
        }

        function getItems($module_srl, $package_srl) {
            $oFileModel = &getModel('file');

            $args->module_srl = $module_srl;
            $args->package_srl = $package_srl;

            $output = executeQueryArray('resource.getItems', $args);
            if(!$output->data) return array();
            foreach($output->data as $key => $val) {
                if($val->voter>0) $val->star = (int)($val->voted/$val->voter);
                else $val->star = 0;
                $output->data[$key]->download_url = getFullUrl().$oFileModel->getDownloadUrl($val->file_srl, $val->sid);
            }

            return $output->data;
        }

        function getLatestItemList($module_srl, $category_srl = null, $childs = null, $member_srl = null, $search_keyword = null, $order_target = 'package.update_order', $order_type = 'asc') {
            $oFileModel = &getModel('file');

            $args->module_srl = $module_srl;

            if(!is_null($childs) && preg_match('/^([0-9])([0-9,]+)([0-9])$/', $childs)) $args->category_srl = $childs;
            else if(!is_null($category_srl)) $args->category_srl = $category_srl;
            else $args->idx_category_srl = 0;

            if(!is_null($member_srl)) $args->member_srl = $member_srl;

            if($search_keyword) {
                $tr = explode(' ',$search_keyword);
                for($i=0,$c=count($tr);$i<$c;$i++) {
                    if(trim($tr[$i])) $t[] = trim($tr[$i]);
                }
                if(count($t)) $args->search_keyword = implode('%', $t);
            }

            $args->order_type = $order_type;
            if($order_target == 'latest') $args->sort_index = 'package.last_update';
            elseif($order_target == 'popular') $args->sort_index = 'package.voted';
            else $args->sort_index = 'package.list_order';

            $output = executeQueryArray('resource.getLatestItemList', $args);
            if($output->data) {
                foreach($output->data as $key => $val) {
{'fraction_non_alphanumeric': 0.16490954054405832, 'fraction_numerical': 0.0028634647923988024, 'mean_word_length': 2.2326461926798484, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 108, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5900527', 'n_tokens_mistral': 2485, 'n_tokens_neox': 2425, 'n_words': 384}