forked from codemaster08240328/aws-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpseudoCode.txt
54 lines (42 loc) · 1.36 KB
/
pseudoCode.txt
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
50
51
52
53
54
exports.handler = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'SQS event processed.',
input: event,
}),
};
var body = event.Records[0].body;
foreach (body as phrase) {
sql = "select * from phrases where phrase_name = phrase.phrase"
if (sql) {
"update phrases set update_time=now() where id = sql.id"
return phrase.id from the DB
}
else {
"insert into phrases...."
return phrase.id from the DB
}
sql1 = "select * from data WHERE phrase_id = phrase.id AND volume_type = 'estimate' and volume_date = phrase.volumeEstimatedAt and volume = phrase.volumeEstimate"
if (sql1) {
update update_time=now()
} else {
insert
}
foreach (phrase.volumeEstimateHistorical as volumeHistorical) {
sql2 = "select * from data WHERE phrase_id = phrase.id AND volume_type = 'estimate' and volume_date = volumeHistorical.dateTime and volume = volumeHistorical.value"
if (sql2) {
update update_time=now()
} else {
insert
}
}
foreach (phrase.volumeExactHistorical as volumeExact) {
sql2 = "select * from data WHERE phrase_id = phrase.id AND volume_type = 'exact' and volume_date = volumeExact.dateTime and volume = volumeExact.value"
if (sql2) {
update update_time=now()
} else {
insert
}
}
}