-
Notifications
You must be signed in to change notification settings - Fork 3
Log items that share the same UUID #53
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
9790b58
f19fcc8
4aea460
e4bb3c8
b6dc388
93da255
cae791d
5b37912
6f7a97f
1c1d78a
d04c2cf
9d8e1c8
12229de
3cd5020
d33e8d9
9b0b9a6
e773185
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 |
|---|---|---|
| @@ -1,13 +1,14 @@ | ||
| const google = require('googleapis'); | ||
| const keys = require('./config/keys'); | ||
|
|
||
| function rowToObject(val, lab, index) { | ||
| const o = {}; | ||
| for (let i = 0; i < lab.length; i += 1) { | ||
| o[lab[i]] = val[i]; | ||
| // creates a dictionary mapping column names with the values | ||
| // ex: { floor : 402, business : coworking, etc..} | ||
| function spreadsheetValuesToObject(values, columns) { | ||
| const formatedRow = {}; | ||
| for (let i = 0; i < columns.length; i += 1) { | ||
| formatedRow[columns[i]] = values[i]; | ||
| } | ||
| o.cellRef = 'https://docs.google.com/spreadsheets/d/1QHKa3vUpht7zRl_LEzl3BlUbolz3ZiL8yKHzdBL42dY/edit#gid=0&range=A' + index + ':T' + index; | ||
| return o; | ||
| return formatedRow; | ||
| } | ||
|
|
||
| function loadDatabase(callback) { | ||
|
|
@@ -21,8 +22,10 @@ function loadDatabase(callback) { | |
| console.log(`The API returned an error: ${err}`); | ||
| return; | ||
| } | ||
| return callback(response.values.map((row, index) => | ||
| rowToObject(row, response.values[0], index + 1)).splice(1)); | ||
| const columns = response.values[0]; | ||
| // map function transforms a list into another list using the given lambda function | ||
| const formatedRows = response.values.map(row => spreadsheetValuesToObject(row, columns)); | ||
| return callback(formatedRows); | ||
| }); | ||
|
Member
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. introducing redundant local variable is not recommended. It can be a symptom of poor function breakdown
Contributor
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 actually meant to break into two steps for better readability,
Member
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. Extracting local variable is usually bad design.
Contributor
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 don't understand what "Extracting subfunction" means.
Member
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.
|
||
| } | ||
|
|
||
|
|
||
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.
not a good practice to mix refactoring and altering behaviour ( i.e. deleting cellRef)
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.
and now the template for
http:///recentdisplay irrelevant links to home page.