-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyTests.js
46 lines (40 loc) · 1.41 KB
/
myTests.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
const ff = bmFolderFun.paths(DriveApp)
const fromPath = 'worldpublic';
function testPileOfFiles() {
const fromPath = '/mydata/family/Jim/identities';
// force a permission dialog with this comment
// DriveApp.getRootFolder()
console.log(`Simple File List for: ${fromPath}:`);
console.log(ff.pileOfFiles({ start: fromPath }));
console.log(`Simple Image File List for: ${fromPath} (NO SUBFOLDERS):`);
console.log(ff.pileOfFiles({
start: fromPath,
mimeTypes: ['image/jpeg', 'image/png'],
includeSubfolders: false
}))
const theseMimeTypes =[ 'application/vnd.google-apps.document'];
console.log(`Simple Folder List for: ${fromPath} AND COUNT OF ${JSON.stringify(theseMimeTypes)}`);
const pile = ff.pileOfFiles({
includeSubfolders: true,
start: fromPath,
mimeTypes: theseMimeTypes
})
// dedup by folder path
const map = new Map(pile.map(({folderPath})=>([folderPath, 0])))
// count by folder path
pile.forEach (p=>map.set(p.folderPath,map.get(p.folderPath)+1))
console.log(Array.from(map).map(([folderPath, count])=>({
folderPath,
count
})))
}
function getStockPrice() {
var symbol = "AAPL";
var url = "https://finance.google.com/finance/quote/" + symbol + ":NASDAQ?output=json";
Logger.log(url);
var response = UrlFetchApp.fetch(url);
var content = response.getContentText();
var json = JSON.parse(content.substring(6));
var price = json[0].l;
return price;
}