create account

RE: Adding SQLite support & reroll functionality to the Discord Raffle Bot by emrebeyler

View this thread on: hive.blogpeakd.comecency.com

Viewing a response to: @jestemkioskiem/adding-sqlite-support-and-reroll-functionality-to-the-discord-raffle-bot

· @emrebeyler ·
$3.03
I am really proud of your progress on your Python journey. :)

A couple of minor feedbacks:


- Indentation levels

![Screen Shot 2018-08-02 at 9.42.55 AM.png](https://cdn.steemitimages.com/DQmQTbV7xF5SFZQnVJSdx9VxiAY83fkghx3WSsNNsSgDsww/Screen%20Shot%202018-08-02%20at%209.42.55%20AM.png)

I have counted almost 4 indentation levels in the code. For the reader, that makes the program hard to understand.

You go into a different state in each if/for/ block. It reminds me [this](https://www.reddit.com/r/ProgrammerHumor/comments/27yykv/indent_hadouken/) :) 

You can alternatively check the opposite condition and make less levels of indentations.

Instead of this:

```
if utils.permission_check(self.author, config.permitted_roles):
   # ... do stuff
   # other if/else condifitions

```

This:

```
if not utils.permission_check(self.author, config.permitted_roles):
	# send permission error
	return

# ... do stuff
# other if/else condifitions

```

This will help the code readers a lot since we don't have interpret/remember the code in our heads in every indentation level.

- Using a **blocking** SQLite library

Asyncio is a non blocking library, thus if you use it you should use all your companian libraries async.

[Here](https://github.com/jreese/aiosqlite) is a asyncio portable SQLite library you can find.

Running blocking functions in an async environments hurts the application reactivity very [bad on certain cases](https://docs.python.org/3.6/library/asyncio-dev.html#handle-blocking-functions-correctly).

Even though, you won't feel the impact in small scale, it's good to use non-blocking libraries with asyncio.

***

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/2322211).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
👍  , , , ,
properties (23)
authoremrebeyler
permlinkre-jestemkioskiem-adding-sqlite-support-and-reroll-functionality-to-the-discord-raffle-bot-20180802t065609592z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"image":["https://cdn.steemitimages.com/DQmQTbV7xF5SFZQnVJSdx9VxiAY83fkghx3WSsNNsSgDsww/Screen%20Shot%202018-08-02%20at%209.42.55%20AM.png"],"links":["https://www.reddit.com/r/ProgrammerHumor/comments/27yykv/indent_hadouken/","https://github.com/jreese/aiosqlite","https://docs.python.org/3.6/library/asyncio-dev.html#handle-blocking-functions-correctly","https://join.utopian.io/guidelines","https://review.utopian.io/result/3/2322211","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-08-02 06:56:09
last_update2018-08-02 06:56:09
depth1
children1
last_payout2018-08-09 06:56:09
cashout_time1969-12-31 23:59:59
total_payout_value2.274 HBD
curator_payout_value0.753 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,134
author_reputation448,535,049,068,622
root_title"Adding SQLite support & reroll functionality to the Discord Raffle Bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,846,270
net_rshares1,792,292,955,569
author_curate_reward""
vote details (5)
@jestemkioskiem · (edited)
Hey!

Your feedback, as always, is incredible. As a self-learner this provides feedback to the exact issues I'm facing without reading through pages and pages of text that addresses issues I am already aware of.

Comments like this are the best part of contributing to Utopian! This is knowledge that will stick with me for the rest of my career when I take it to an actual job.

Thank you so much! Stay awesome!

Edit: Looked into the indetation, you can find the commit [here](https://github.com/Jestemkioskiem/discord-raffle-bot/commit/524cf045f1dcbf793aa8bf0470f770b0f38ce74b), I'll look into the asyncio issue later today. So expect to be positively surprised the next time you see my contribution here!
👍  
properties (23)
authorjestemkioskiem
permlinkre-emrebeyler-re-jestemkioskiem-adding-sqlite-support-and-reroll-functionality-to-the-discord-raffle-bot-20180802t122219931z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"busy/2.5.4","community":"busy","format":"markdown","users":[],"links":["https://github.com/Jestemkioskiem/discord-raffle-bot/commit/524cf045f1dcbf793aa8bf0470f770b0f38ce74b"],"image":[]}
created2018-08-02 12:22:21
last_update2018-08-02 12:49:42
depth2
children0
last_payout2018-08-09 12:22:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length708
author_reputation41,292,066,961,817
root_title"Adding SQLite support & reroll functionality to the Discord Raffle Bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,871,759
net_rshares211,400,357
author_curate_reward""
vote details (1)