2018-12-20 19:23:16 +03:00
import urllib
2019-02-21 11:43:35 +03:00
import database
2018-12-29 18:57:52 +03:00
from htmlgenerators import artistLink
2018-12-20 19:23:16 +03:00
2019-02-21 11:43:35 +03:00
def instructions ( keys ) :
2018-12-20 19:23:16 +03:00
2019-02-21 11:43:35 +03:00
db_data = database . issues ( )
2018-12-20 19:23:16 +03:00
i = 0
2018-12-22 02:31:27 +03:00
html = " <table class= ' list ' > "
2018-12-21 18:32:21 +03:00
if db_data [ " inconsistent " ] :
html + = " <tr> "
html + = " <td>The current database wasn ' t built with all current rules in effect. Any problem below might be a false alarm and fixing it could create redundant rules.</td> "
2018-12-22 14:47:49 +03:00
html + = """ <td class= ' button important ' onclick= " fullrebuild() " ><div>Rebuild the database</div></td> """
2018-12-21 18:32:21 +03:00
html + = " </tr> "
i + = 1
2018-12-20 19:23:16 +03:00
for d in db_data [ " duplicates " ] :
html + = " <tr> "
html + = " <td> ' " + artistLink ( d [ 0 ] ) + " ' "
html + = " is a possible duplicate of "
html + = " ' " + artistLink ( d [ 1 ] ) + " ' </td> "
2018-12-22 14:47:49 +03:00
html + = """ <td class= ' button ' onclick= " newrule(this, ' replaceartist ' , ' """ + d [ 0 ] + """ ' , ' """ + d [ 1 ] + """ ' ) " ><div> """ + d [ 1 ] + """ is correct</div></td> """
html + = """ <td class= ' button ' onclick= " newrule(this, ' replaceartist ' , ' """ + d [ 1 ] + """ ' , ' """ + d [ 0 ] + """ ' ) " ><div> """ + d [ 0 ] + """ is correct</div></td> """
2018-12-20 19:23:16 +03:00
html + = " </tr> "
i + = 1
for c in db_data [ " combined " ] :
html + = " <tr> "
html + = " <td> ' " + artistLink ( c [ 0 ] ) + " ' sounds like the combination of " + str ( len ( c [ 1 ] ) ) + " artists: "
for a in c [ 1 ] :
html + = " ' " + artistLink ( a ) + " ' "
html + = " </td> "
2018-12-22 14:47:49 +03:00
html + = """ <td class= ' button ' onclick= " newrule(this, ' replaceartist ' , ' """ + c [ 0 ] + """ ' , ' """ + " ␟ " . join ( c [ 1 ] ) + """ ' ) " ><div>Fix it</div></td> """
2018-12-20 19:23:16 +03:00
html + = " </tr> "
i + = 1
for n in db_data [ " newartists " ] :
html + = " <tr> "
html + = " <td>Is ' " + n [ 0 ] + " ' in ' " + artistLink ( n [ 1 ] ) + " ' an artist?</td> "
2018-12-22 14:47:49 +03:00
html + = """ <td class= ' button ' onclick= " newrule(this, ' replaceartist ' , ' """ + n [ 1 ] + """ ' , ' """ + " ␟ " . join ( n [ 2 ] + [ n [ 0 ] ] ) + """ ' ) " ><div>Yes</div></td> """
2018-12-20 19:23:16 +03:00
html + = " </tr> "
i + = 1
html + = " </table> "
2019-02-17 16:25:40 +03:00
return ( { " KEY_ISSUESLIST " : html , " KEY_ISSUES " : str ( i ) } , [ ] )