<commit_before>#include "Album.h"

/* constructors */
Album::Album(Locutus *locutus) {
	this->locutus = locutus;
	artist = new Artist(locutus);
	mbid = "";
	title = "";
	released = "";
	type = "";
}

/* destructors */
Album::~Album() {
	for (vector<Track *>::size_type t = 0; t < tracks.size(); ++t)
		delete tracks[t];
	delete artist;
}

/* methods */
bool Album::loadFromCache(const string &mbid) {
	/* fetch album from cache */
	if (locutus == NULL)
		return false;
	if (mbid.size() != 36) {
		string msg = "Unable to load album from cache. Illegal MusicBrainz ID: ";
		msg.append(mbid);
		locutus->debug(DEBUG_NOTICE, msg);
		return false;
	}
	ostringstream query;
	query << "SELECT * FROM v_album_lookup WHERE album_mbid = '" << locutus->database->escapeString(mbid) << "' AND last_updated + INTERVAL '" << locutus->album_cache_lifetime << " months' < now()";
	if (!locutus->database->query(query.str()) || locutus->database->getRows() <= 0) {
		/* album not in cache */
		string msg = "Unable to load album from cache. MusicBrainz ID not found or cache is too old: ";
		msg.append(mbid);
		locutus->debug(DEBUG_NOTICE, msg);
		return false;
	}
	/* artist data */
	artist->mbid = locutus->database->getString(0, 0);
	artist->name = locutus->database->getString(0, 1);
	artist->sortname = locutus->database->getString(0, 2);
	/* album data */
	this->mbid = locutus->database->getString(0, 3);
	type = locutus->database->getString(0, 4);
	title = locutus->database->getString(0, 5);
	released = locutus->database->getString(0, 6);
	/* track data */
	int trackcount = locutus->database->getRows();
	tracks.resize(trackcount, NULL);
	for (int t = 0; t < trackcount; ++t) {
		/* we could reduce memory usage here.
		 * we'll get the same artist stored <trackcount> times.
		 * since each artist entry usually eats about 64 bytes mem,
		 * it's hardly necessary to improve this, though */
		Artist *track_artist = new Artist(locutus);
		Track *track = new Track(locutus, this, track_artist);
		/* track data */
		track->mbid = locutus->database->getString(t, 7);
		track->title = locutus->database->getString(t, 8);
		track->duration = locutus->database->getInt(t, 9);<commit_msg>another mistake with "<" & ">". loading albums from cache (database) should work now<commit_after>#include "Album.h"

/* constructors */
Album::Album(Locutus *locutus) {
	this->locutus = locutus;
	artist = new Artist(locutus);
	mbid = "";
	title = "";
	released = "";
	type = "";
}

/* destructors */
Album::~Album() {
	for (vector<Track *>::size_type t = 0; t < tracks.size(); ++t)
		delete tracks[t];
	delete artist;
}

/* methods */
bool Album::loadFromCache(const string &mbid) {
	/* fetch album from cache */
	if (locutus == NULL)
		return false;
	if (mbid.size() != 36) {
		string msg = "Unable to load album from cache. Illegal MusicBrainz ID: ";
		msg.append(mbid);
		locutus->debug(DEBUG_NOTICE, msg);
		return false;
	}
	ostringstream query;
	query << "SELECT * FROM v_album_lookup WHERE album_mbid = '" << locutus->database->escapeString(mbid) << "' AND last_updated + INTERVAL '" << locutus->album_cache_lifetime << " months' > now()";
	if (!locutus->database->query(query.str()) || locutus->database->getRows() <= 0) {
		/* album not in cache */
		string msg = "Unable to load album from cache. MusicBrainz ID not found or cache is too old: ";
		msg.append(mbid);
		locutus->debug(DEBUG_NOTICE, msg);
		return false;
	}
	/* artist data */
	artist->mbid = locutus->database->getString(0, 0);
	artist->name = locutus->database->getString(0, 1);
	artist->sortname = locutus->database->getString(0, 2);
	/* album data */
	this->mbid = locutus->database->getString(0, 3);
	type = locutus->database->getString(0, 4);
	title = locutus->database->getString(0, 5);
	released = locutus->database->getString(0, 6);
	/* track data */
	int trackcount = locutus->database->getRows();
	tracks.resize(trackcount, NULL);
	for (int t = 0; t < trackcount; ++t) {
		/* we could reduce memory usage here.
		 * we'll get the same artist stored <trackcount> times.
		 * since each artist entry usually eats about 64 bytes mem,
		 * it's hardly necessary to improve this, though */
		Artist *track_artist = new Artist(locutus);
		Track *track = new Track(locutus, this, track_artist);
		/* track data */
		track->mbid = locutus->database->getString(t, 7);
		track->title = locutus->database->getString(t, 8);
		track->duration = locutus->database->getInt(t, 9);
{'fraction_non_alphanumeric': 0.16843531271167306, 'fraction_numerical': 0.010837660871528562, 'mean_word_length': 4.133256083429896, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 87, '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': '3760354', 'n_tokens_mistral': 1613, 'n_tokens_neox': 1509, 'n_words': 403}