<commit_before><?php

include __DIR__.'/Artist.php';

/**
 * ArtistManager
 * 
 *
 * @author Diego
 */
class ArtistManager extends CI_Model {
    
   
    /*
     * Constructor
     */
    public function __construct() {
        parent::__construct();
        $this->load->model('LastFM');
        $this->load->model('/CRUD/Artist_model');
        $this->load->model('/CRUD/LastfmArtist_model');
        $this->load->model('/CRUD/Album_model');
        $this->load->model('/CRUD/Fan_model');
        $this->load->model('/CRUD/ArtistFan_model');
        $this->load->model('/CRUD/Tag_model');
        $this->load->model('/CRUD/ArtistTag_model');
        $this->load->model('/CRUD/SimilarArtist_model');
    }
    
    /*
     * DB queries *
     */
    
    /*
     * Has lastfm
     * @param String $artist
     * @return Boolean 
     */
    public function hasLastFM ($artist) {
        if ($this->LastFM->getArtist() != false) {
            return true;   
        } else {
            return false;
        }
        
    }
    
    public function getArtist ($artist) {
        $this->getInfoFromLastFM($artist);
        return new Artist($artist);
    }

    /*******************/
    /* Proxy functions */
    /*******************/
    
    private function getInfoFromLastFM ($artist) {
        $this->getArtistFromLastFM($artist);
        $this->getAlbumsFromLastFM($artist);
        $this->getTagsFromLastFM($artist);
        $this->getFansFromLastFM($artist);
        $this->getSimilarFromLastFM($artist);
    }
    
    private function getArtistFromLastFM($artist) {
        
        // Insert name in Artists
        $id = $this->Artist_model->insert(array('name' => $artist));
        
        // Get id
        if ($id == FALSE){
            return FALSE;
        }
        
        // Get LastfmArtist 
        $lastfmArtist = $this->LastFM->getArtist($artist);
        
        if ($lastfmArtist == FALSE) {
            return FALSE;
        }
        
        // Insert in LastfmArtists
        $lastfmId = $this->LastfmArtist_model->insert(array(
            'url' => $lastfmArtist->artist->url,
            'image' => $lastfmArtist->artist->image[3]->{'#text'}
        ));
        
        if ($lastfmId == FALSE) {<commit_msg>Only albums<commit_after><?php

include __DIR__.'/Artist.php';

/**
 * ArtistManager
 * 
 *
 * @author Diego
 */
class ArtistManager extends CI_Model {
    
   
    /*
     * Constructor
     */
    public function __construct() {
        parent::__construct();
        $this->load->model('LastFM');
        $this->load->model('/CRUD/Artist_model');
        $this->load->model('/CRUD/LastfmArtist_model');
        $this->load->model('/CRUD/Album_model');
        $this->load->model('/CRUD/Fan_model');
        $this->load->model('/CRUD/ArtistFan_model');
        $this->load->model('/CRUD/Tag_model');
        $this->load->model('/CRUD/ArtistTag_model');
        $this->load->model('/CRUD/SimilarArtist_model');
    }
    
    /*
     * DB queries *
     */
    
    /*
     * Has lastfm
     * @param String $artist
     * @return Boolean 
     */
    public function hasLastFM ($artist) {
        if ($this->LastFM->getArtist() != false) {
            return true;   
        } else {
            return false;
        }
        
    }
    
    public function getArtist ($artist) {
        $this->getInfoFromLastFM($artist);
        return new Artist($artist);
    }

    /*******************/
    /* Proxy functions */
    /*******************/
    
    private function getInfoFromLastFM ($artist) {
        //$this->getArtistFromLastFM($artist);
        $this->getAlbumsFromLastFM($artist);
        //$this->getTagsFromLastFM($artist);
        //$this->getFansFromLastFM($artist);
        //$this->getSimilarFromLastFM($artist);
    }
    
    private function getArtistFromLastFM($artist) {
        
        // Insert name in Artists
        $id = $this->Artist_model->insert(array('name' => $artist));
        
        // Get id
        if ($id == FALSE){
            return FALSE;
        }
        
        // Get LastfmArtist 
        $lastfmArtist = $this->LastFM->getArtist($artist);
        
        if ($lastfmArtist == FALSE) {
            return FALSE;
        }
        
        // Insert in LastfmArtists
        $lastfmId = $this->LastfmArtist_model->insert(array(
            'url' => $lastfmArtist->artist->url,
            'image' => $lastfmArtist->artist->image[3]->{'#text'}
        ));
        
        if ($lastfmId == FALSE) {
{'fraction_non_alphanumeric': 0.17236783651710352, 'fraction_numerical': 0.000444247001332741, 'mean_word_length': 1.8645038167938932, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 83, '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': '5307500', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1393, 'n_words': 205}