#example script gets every single mii in the DB, then adds it to spot_list ql = QuickList() pr = Prepare() miilist = [] artisanlist = [] miidata = 'gAoAPwAAAAAAAAAAAAAAAAAAAAAAAF4AhonbB8JJnRIgBDxAuX0ookiKBEAAMZkEAIoAiiUEAAAAAAAAAAAAAAAAAAAAAAAAAAAaLw==' likes = 0 skill = 0 country = 49 initial = 'AA' artisandata = 'gAsAUABlAGUAdwBlAGUAAAAAAAAAAAAAhorkD1RU1sYgADxAub0IPAiQCEAUabiQAIoAiiUEAAAAAAAAAAAAAAAAAAAAAAAAAAC68Q==' master = 0 ResetList(b'NL') for i in range(499): miilist.append((i, initial, likes, skill, country, miidata) + (artisandata, i, master)) list_type = 'NL' data = ql.build(list_type, miilist) with open('150/new_list01.ces', 'wb') as file: file.write(pr.prepare(data)) with open('150/new_list01.dec', 'wb') as file: file.write(data)
extraCount = 0 count = 100 else: extraCount = 100 - count cursor.execute( 'SELECT mii.entryno, mii.initial, mii.permlikes, mii.skill, mii.country, mii.miidata, artisan.miidata, artisan.craftsno, artisan.master FROM mii, artisan WHERE mii.craftsno=artisan.craftsno ORDER BY mii.likes DESC LIMIT %s', [count]) popularMiis = cursor.fetchall() cursor.execute( 'SELECT mii.entryno, mii.initial, mii.permlikes, mii.skill, mii.country, mii.miidata, artisan.miidata, artisan.craftsno, artisan.master FROM mii, artisan WHERE mii.permlikes < 25 AND mii.craftsno=artisan.craftsno ORDER BY mii.permlikes DESC LIMIT %s', [extraCount]) extraMiis = cursor.fetchall() cursor.execute('UPDATE mii SET likes = 0' ) #reset everyone's likes, but not their permlikes db.commit() db.close() data = ql.build('SL', (popularMiis + extraMiis)) with open('{}/150/spot_list.ces'.format(config['miicontest_path']), 'wb') as file: file.write(pr.prepare(data)) with open('decfiles/spot_list.dec', 'wb') as file: file.write(data)
miilist = [] for i in range(len( numbers)): #add the artisan data to each mii based on their craftsno cursor.execute( 'SELECT entryno,initial,permlikes,skill,country,miidata FROM mii WHERE craftsno = %s AND entryno = %s', (numbers[i][0], numbers[i][1])) mii = cursor.fetchone() cursor.execute( 'SELECT miidata,craftsno,master FROM artisan WHERE craftsno = %s', [numbers[i][0]]) artisan = cursor.fetchone() if artisan == None: with open('./logs/top50.log', 'a') as log: log.write( 'ERROR: ENTRYNO {} HAS NO EXISTING ARTISAN WITH CRAFTSNO {}\n'. format(numbers[i][1], numbers[i][0])) print('ERROR: ENTRYNO {} HAS NO EXISTING ARTISAN WITH CRAFTSNO {}\n'. format(numbers[i][1], numbers[i][0])) pass else: miilist.append(mii + artisan) data = ql.build('PL', miilist) sleep(30) with open('{}/150/pop_list.ces'.format(config['miicontest_path']), 'wb') as file: file.write(pr.prepare(data))
"SELECT mii.entryno, mii.initial, mii.permlikes, mii.skill, mii.country, mii.miidata, artisan.miidata, artisan.craftsno, artisan.master FROM mii, artisan WHERE mii.craftsno=artisan.craftsno ORDER BY mii.likes DESC LIMIT %s", [count], ) popularMiis = cursor.fetchall() cursor.execute( "SELECT mii.entryno, mii.initial, mii.permlikes, mii.skill, mii.country, mii.miidata, artisan.miidata, artisan.craftsno, artisan.master FROM mii, artisan WHERE mii.permlikes < 25 AND mii.craftsno=artisan.craftsno ORDER BY mii.permlikes DESC LIMIT %s", [extraCount], ) extraMiis = cursor.fetchall() cursor.execute("UPDATE mii SET likes = 0" ) # reset everyone's likes, but not their permlikes db.commit() db.close() for country in [0, 150]: # gets the most popular miis ordered by their volatile likes which resets to 0 when spot_list resets ql = QuickList() pr = Prepare() data = ql.build("SL", (popularMiis + extraMiis), country) with open("{}/{}/spot_list.ces".format(config["miicontest_path"], country), "wb") as file: file.write(pr.prepare(data)) with open("decfiles/spot_list.dec", "wb") as file: file.write(data)
from cmoc import QuickList, Prepare, ResetList import MySQLdb from json import load from time import sleep with open("/var/rc24/File-Maker/Channels/Check_Mii_Out_Channel/config.json", "r") as f: config = load(f) # get the top 50 most popular miis sorted by their permanent likes and add them to pop_list db = MySQLdb.connect("localhost", config["dbuser"], config["dbpass"], "cmoc") cursor = db.cursor() cursor.execute( "SELECT mii.entryno, mii.initial, mii.permlikes, mii.skill, mii.country, mii.miidata, artisan.miidata, artisan.craftsno, artisan.master FROM mii, artisan WHERE mii.craftsno=artisan.craftsno ORDER BY permlikes DESC LIMIT 50" ) miilist = cursor.fetchall() for country in [0, 150]: ql = QuickList() pr = Prepare() data = ql.build("PL", miilist, country) with open( "{}/{}/pop_list.ces".format(config["miicontest_path"], country), "wb" ) as file: file.write(pr.prepare(data))
[numbers[i][0]]) artisan = cursor.fetchone() if artisan == None: with open('./logs/popular.log', 'a') as log: log.write( 'ERROR: ENTRYNO {} HAS NO EXISTING ARTISAN WITH CRAFTSNO {}\n'. format(numbers[i][1], numbers[i][0])) print('ERROR: ENTRYNO {} HAS NO EXISTING ARTISAN WITH CRAFTSNO {}\n'. format(numbers[i][1], numbers[i][0])) pass else: miilist.append(mii + artisan) cursor.execute('UPDATE mii SET likes = 0' ) #reset everyone's likes, but not their permlikes db.commit() db.close() data = ql.build('SL', miilist) sleep(5) #5 seconds for the other scripts to finish with open('{}/150/spot_list.ces'.format(config['miicontest_path']), 'wb') as file: file.write(pr.prepare(data)) with open('decfiles/spot_list.dec', 'wb') as file: file.write(data)