-
Notifications
You must be signed in to change notification settings - Fork 80
Analysis cart creation #1025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analysis cart creation #1025
Changes from 1 commit
90339fd
72267a0
10f077d
f1ca570
e362c25
cfe9ba2
28f8480
f0c3f80
6d30936
4f3756f
b5bf4ed
68488c7
90b3de2
bd3d513
f5026f8
874632b
ddf2ff4
1dc1440
cf1123f
15c71dc
8e129e6
e784006
d7b4778
ba42c6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,10 +224,21 @@ def create(cls, email, password, info=None): | |
# for sql insertion | ||
columns = info.keys() | ||
values = [info[col] for col in columns] | ||
|
||
queue = "add_user_%s" % email | ||
conn_handler.create_queue(queue) | ||
# crete user | ||
sql = ("INSERT INTO qiita.%s (%s) VALUES (%s)" % | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know you have not touch this code, but we have been (more or less) consistently using format for this type of changes. I would appreciate if you can change that. Non blocking... |
||
(cls._table, ','.join(columns), ','.join(['%s'] * len(values)))) | ||
conn_handler.execute(sql, values) | ||
conn_handler.add_to_queue(queue, sql, values) | ||
# create user default sample holder | ||
sql = ("INSERT INTO qiita.analysis " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is personal opinion but I think this highly improves code readability and even when failures happen they're easier to read on the command line. Instead of using quotes ("), I like to user triple quotes (""") and then align the SQL in a easy to read way. In this example: sql = """INSERT INTO qiita.analysis
(email, name, description, dflt, analysis_status_id)
VALUES (%s, %s, %s, %s, 1)""" The cool thing about this, is that if the query fails, it gets also formatted on the CLI. Also it is a more natural way of reading SQL as things align better (note the small indentation on the column names). This is not blocking though... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can do this, but it is also something to put in contributing.md and needs to be consistently done across the entire codebase. Again, if that's agreeable I will make the change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's not on contributing so no worries if you don't want to change it. I'm doing it as I'm changing other parts of the code, but there is no documentation at this point. |
||
"(email, name, description, dflt, analysis_status_id) " | ||
"VALUES (%s, %s, %s, %s, 1)") | ||
conn_handler.add_to_queue(queue, sql, | ||
(email, '%s-dflt' % email, 'dflt', True)) | ||
|
||
conn_handler.execute_queue(queue) | ||
|
||
return cls(email) | ||
|
||
@classmethod | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm... from my point of view, is usually better to ask the user: give me your default cart. It will be a instance method rather than a classmethod, which is already a signal of better design...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows you to return the actual object already instantiated, as opposed to just the ID and instantiating, saving a DB call. Do we care about the extra DB call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not saving any DB call...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check if ID exists on Analysis instantiation isn't needed in this case. That's the DB call I'm referring to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That call is executed when you are doing
cls(aid)
(It is calling the init)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, didn't realize that. Sure, can make that change then.