-
Notifications
You must be signed in to change notification settings - Fork 892
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
Fixes panel query for the publisher #1642
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,17 +307,17 @@ PublisherInfoDatabase::GetPanelPublisher( | |
} | ||
|
||
sql::Statement info_sql(db_.GetUniqueStatement( | ||
"SELECT pi.publisher_id, pi.name, pi.url, pi.favIcon, pi.provider, " | ||
"pi.verified, pi.excluded, ai.percent FROM publisher_info AS pi " | ||
"LEFT JOIN activity_info AS ai ON pi.publisher_id = ai.publisher_id " | ||
"WHERE pi.publisher_id=? AND ((ai.month = ? " | ||
"AND ai.year = ? AND ai.reconcile_stamp = ?) OR " | ||
"ai.percent IS NULL) LIMIT 1")); | ||
"SELECT pi.publisher_id, pi.name, pi.url, pi.favIcon, " | ||
"pi.provider, pi.verified, pi.excluded, " | ||
"(" | ||
"SELECT IFNULL(percent, 0) FROM activity_info WHERE " | ||
"publisher_id = ? AND reconcile_stamp = ? " | ||
") as percent " | ||
"FROM publisher_info AS pi WHERE pi.publisher_id = ? LIMIT 1")); | ||
|
||
info_sql.BindString(0, filter.id); | ||
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. instead of hard-coding the number, you might initialize a variable (unsigned char, unsigned short, etc) to 0 and just ++ it on each field
|
||
info_sql.BindInt(1, filter.month); | ||
info_sql.BindInt(2, filter.year); | ||
info_sql.BindInt64(3, filter.reconcile_stamp); | ||
info_sql.BindInt64(1, filter.reconcile_stamp); | ||
info_sql.BindString(2, filter.id); | ||
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. ID is being returned twice here; field 0 and 2. Is that correct? 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. yes, we bind id in two places |
||
|
||
if (info_sql.Step()) { | ||
std::unique_ptr<ledger::PublisherInfo> info; | ||
|
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.
I know this isn't the original PR; but I would recommend looking at situations where using a view makes sense (instead putting the select statement here). With a view, you can select from it like a table and there's a possibility you can re-use the view in other methods. Kind of nice because you abstract away the joins and basically just have the business logic in here