Skip to content

Instantly share code, notes, and snippets.

@itanium21
Last active August 29, 2015 14:07
Show Gist options
  • Save itanium21/e2389e9e454d2cd8167a to your computer and use it in GitHub Desktop.
Save itanium21/e2389e9e454d2cd8167a to your computer and use it in GitHub Desktop.
#player_id, name un i (līmenis) tiek padots
cursor.execute("SELECT score FROM scores WHERE level="+str(i)+" AND player_id="+player_id)
score=cursor.fetchone()[0]
cursor.execute("SELECT COUNT(1) FROM scores WHERE score>="+ str(score) + " AND level="+str(i))
count_1=cursor.fetchone()[0]
cursor.execute("SELECT timestamp FROM scores WHERE level="+str(i)+ " AND player_id="+player_id)
timestamp=cursor.fetchone()[0]
cursor.execute("SELECT COUNT(1) FROM scores WHERE level="+str(i) +" AND score=" + str(score) + " AND timestamp<'"+str(timestamp)+"'")
count_2=cursor.fetchone()[0]
cursor.execute("SELECT COUNT(1) FROM players JOIN scores ON scores.player_id=players.id WHERE level="+str(i)+" AND score="+str(score)+" AND timestamp='"+str(timestamp)+"' AND name < '"+ name +"'")
count_3=cursor.fetchone()[0]
app.logger.info(int(count_1)-int(count_2)-int(count_3)) #rezultāts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment