Skip to content

Commit

Permalink
Start working on howgud (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
krofna committed Jul 14, 2019
1 parent 2e7885c commit ddc6b71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tle/cogs/codeforces.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,15 @@ async def gotgud(self, ctx):
else:
await ctx.send('You have already claimed your points')

@commands.command(brief='Print gitgud report card')
@cf_common.user_guard(group='gitgud')
async def howgud(self, ctx, member: discord.Member):
num = cf_common.user_db.howgud(member.id)[0][0]
await ctx.send(f'{member.display_name} completed {num} challenges.')

@commands.command(brief='Skip challenge')
@cf_common.user_guard(group='gitgud')
async def nogud(self, ctx):
await cf_common.resolve_handles(ctx, self.converter, ('!' + str(ctx.author),))
user_id = ctx.message.author.id
active = cf_common.user_db.check_challenge(user_id)
if not active:
Expand Down
6 changes: 6 additions & 0 deletions tle/util/db/user_db_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ def get_gudgitters(self):
'''
return self.conn.execute(query).fetchall()

def howgud(self, user_id):
query = '''
SELECT num_completed FROM user_challenge WHERE user_id = ?
'''
return self.conn.execute(query, (user_id,)).fetchall()

def complete_challenge(self, user_id, challenge_id, finish_time, delta):
query1 = '''
UPDATE challenge SET finish_time = ?, status = 0
Expand Down

0 comments on commit ddc6b71

Please sign in to comment.