-
Notifications
You must be signed in to change notification settings - Fork 0
/
Event listing.js
49 lines (37 loc) · 1.51 KB
/
Event listing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function readEvents() {
var conn = Jdbc.getConnection(url, username, password);
var stmt = conn.createStatement();
// select distinct product_id, order_item_name from wp_wc_order_product_augmented where order_item_name LIKE "%Wednesday%" order by product_id desc;
//Wednesday
var spreadsheet = SpreadsheetApp.getActive();
var sheet = spreadsheet.getSheetByName('Sim-Dashboard');
var cell = sheet.getRange('B5').getValues();
// Event Listing
//
var results = stmt.executeQuery('select distinct order_item_name, product_id from wp_order_product_customer_lookup where memberbot_order_category LIKE "%outdoor%" order by product_id desc');
//console.log(results);
var metaData=results.getMetaData();
var numCols = metaData.getColumnCount();
var spreadsheet = SpreadsheetApp.getActive();
var sheet = spreadsheet.getSheetByName('Event List');
sheet.clearContents();
var arr=[];
for (var col = 0; col < numCols; col++) {
arr.push(metaData.getColumnLabel(col + 1));
}
// https://stackoverflow.com/questions/10585029/parse-an-html-string-with-js
sheet.appendRow(arr);
while (results.next()) {
arr=[];
for (var col = 0; col < numCols; col++) {
arr.push(results.getString(col + 1));
}
sheet.appendRow(arr);
}
sheet.autoResizeColumns(1, numCols+1);
//close SQL
results.close();
stmt.close();
// select distinct product_id, order_item_name from wp_order_product_customer_lookup where order_item_name LIKE "%Wednesday%" AND order_item_name LIKE "%Top%" order by product_id desc;
//end read data function
}