Commit 669ac0ad authored by Gerion Entrup's avatar Gerion Entrup
Browse files

plumber: implement clean_recording

not tested yet
parent 05ea5ffc
......@@ -8,6 +8,7 @@ import threading
from collector import Collector
from model import Recording
from mbdata.models import Release, ReleaseGroup
from utils import get_path
......@@ -55,7 +56,20 @@ class Plumber(threading.Thread):
self.clean_recording(recording)
def clean_recording(self, recording):
pass
self._logger.info("Delete recording " + recording.path)
self.clean_artist_credit(recording.artist_credit, max_references=1)
self._session.delete(recording)
def clean_artist_credit(self, artist_credit, max_references=0):
count = self._session.query(Recording).filter_by(
artist_credit=artist_credit).count()
count += self._session.query(Release).filter_by(
artist_credit=artist_credit).count()
count += self._session.query(ReleaseGroup).filter_by(
artist_credit=artist_credit).count()
if count <= max_references:
self._session.delete(artist_credit)
def clean_database():
pass
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment