Skip to content

Commit 9b16372

Browse files
Merge pull request #83 from sat-utils/misc_fixes
Publish 0.1.0
2 parents ea5a0ca + ef07c65 commit 9b16372

File tree

21 files changed

+89
-89
lines changed

21 files changed

+89
-89
lines changed

.circleci/config.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ jobs:
3535
name: Deploy example to aws
3636
command: |
3737
if [[ "$CIRCLE_BRANCH" == 'master' ]]; then
38-
cd example
39-
yarn
40-
./node_modules/.bin/kes cf deploy --template node_modules/@sat-utils/api/template --deployment dev --region us-east-1 --role arn:aws:iam::552819999234:role/sat-api-deployer-role-DeployerRole-JBBKUABAELDR
38+
#cd example
39+
#yarn
40+
#./node_modules/.bin/kes cf deploy --template node_modules/@sat-utils/api/template --deployment dev --region us-east-1 --role arn:aws:iam::552819999234:role/sat-api-deployer-role-DeployerRole-JBBKUABAELDR
41+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
42+
VERSION=$(jq --raw-output .version lerna.json)
43+
node_modules/.bin/lerna publish --skip-git --repo-version $VERSION --yes --force-publish=*
4144
fi
4245

CHANGES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [v0.1.0] - 2018-09-18
10+
11+
### Fixed
12+
- Fixed broken ingests for Landsat and Sentinel
13+
914
## [v0.0.2]
1015

1116
### Added
@@ -37,6 +42,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3742
- Refactor several modules: metadata, landsat, sentinel
3843
- Refactor and improve splitting
3944

40-
[Unreleased]: https://github.com/sat-utils/sat-api/compare/v0.0.2...HEAD
45+
[Unreleased]: https://github.com/sat-utils/sat-api/compare/v0.1.0...HEAD
46+
[v0.1.0]: https://github.com/sat-utils/sat-api/compare/v0.0.2...v0.1.0
4147
[v0.0.2]: https://github.com/sat-utils/sat-api/compare/legacy-v2.0.0...v0.0.2
4248
[legacy-v2.0.0]: https://github.com/sat-utils/sat-api/tree/legacy

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Sat-api includes a number of NPM packages (in the packages/ directory) that are
3434

3535
$ yarn docs-serve
3636

37-
On Linux, if you get the message "Error: watch *path*/book.json ENOSPC", issue the following command (require sudo access).
37+
On Linux, if you get the message "Error: watch *path*/book.json ENOSPC", issue the following command (requires sudo access).
3838

3939
$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
4040

example/.kes/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ dev:
1414
volumeSize: 80
1515

1616
prod:
17-
stackName: sat-api-v1
17+
stackName: sat-api
1818
system_bucket: sat-api
1919
es:
2020
instanceCount: 2
2121
instanceType: m3.medium.elasticsearch
22-
volumeSize: 80
22+
volumeSize: 80

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lerna": "2.11.0",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"npmClient": "yarn",
55
"packages": [
66
"packages/*"

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
"name": "sat-api",
3-
"version": "1.0.0",
42
"description": "One API to search public Satellites metadata",
53
"main": "index.js",
64
"repository": "https://github.com/sat-utils/sat-api",

packages/api-lib/libs/api.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Search(event, esClient) {
1515
params = event.body
1616
}
1717

18-
this.headers = event.headers
18+
this.endpoint = event.endpoint
1919

2020
this.merge = false
2121
if (_.has(params, 'merge')) {
@@ -34,17 +34,13 @@ function Search(event, esClient) {
3434
this.client = esClient
3535

3636
this.queries = queries(this.params)
37-
38-
console.log(`Queries: ${JSON.stringify(this.queries)}`)
3937
}
4038

4139
// search for items using collection and items
42-
Search.prototype.search_items = (callback) => {
40+
Search.prototype.search_items = function (callback) {
4341
// check collection first
4442
this.search_collections((err, resp) => {
4543
const collections = resp.features.map((c) => c.properties['c:id'])
46-
console.log('matched collections', collections)
47-
console.log('queries before', JSON.stringify(this.queries))
4844
let qs
4945
if (collections.length === 0) {
5046
qs = { bool: { must_not: { exists: { field: 'c:id' } } } }
@@ -62,7 +58,7 @@ Search.prototype.search_items = (callback) => {
6258
}
6359

6460

65-
Search.prototype.search_collections = (callback) => {
61+
Search.prototype.search_collections = function (callback) {
6662
// hacky way to get all collections
6763
const sz = this.size
6864
const frm = this.frm
@@ -92,7 +88,7 @@ Search.prototype.search_collections = (callback) => {
9288
}
9389

9490

95-
Search.prototype.search = (index, callback) => {
91+
Search.prototype.search = function (index, callback) {
9692
const self = this
9793

9894
const searchParams = {
@@ -129,20 +125,15 @@ Search.prototype.search = (index, callback) => {
129125
props = _.omit(props, ['bbox', 'geometry', 'assets', 'links', 'eo:bands'])
130126
const links = body.hits.hits[i]._source.links || []
131127
// add self and collection links
132-
const host = (
133-
'X-Forwarded-Host' in self.headers ?
134-
self.headers['X-Forwarded-Host'] : self.headers.Host
135-
)
136-
const apiUrl = `${self.headers['X-Forwarded-Proto']}://${host}`
137128
let prefix = '/search/stac'
138129
if (index === 'collections') {
139130
prefix = '/collections'
140-
links.self = { rel: 'self', href: `${apiUrl}${prefix}?c:id=${props.collection}` }
131+
links.self = { rel: 'self', href: `${self.endpoint}${prefix}?c:id=${props.collection}` }
141132
}
142133
else {
143-
links.self = { rel: 'self', href: `${apiUrl}${prefix}?id=${props.id}` }
134+
links.self = { rel: 'self', href: `${self.endpoint}${prefix}?id=${props.id}` }
144135
if (_.has(props, 'c:id')) {
145-
links.collection = { href: `${apiUrl}/collections/${props['c:id']}/definition` }
136+
links.collection = { href: `${self.endpoint}/collections/${props['c:id']}/definition` }
146137
}
147138
}
148139
return {

packages/api-lib/libs/es.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function streamToEs(stream, transform, client, index) {
134134
let nRecords = 0
135135
let nTransformed = 0
136136

137-
const toEs = through2({ objectMode: true, consume: true }, (data, encoding, next) => {
137+
const toEs = through2({ objectMode: true, consume: true }, function (data, encoding, next) {
138138
const record = {
139139
index,
140140
type: 'doc',

packages/api-lib/libs/ingest-csv.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
const csv = require('fast-csv')
44
const AWS = require('aws-sdk')
55
const zlib = require('zlib')
6-
const pLimit = require('p-limit')
7-
const lodash = require('lodash')
86
const es = require('./es')
97

108
let esClient
@@ -34,10 +32,9 @@ function invokeLambda(bucket, key, nextFileNum, lastFileNum, arn, retries) {
3432
else {
3533
console.log(`launched ${JSON.stringify(params)}`)
3634
}
37-
}).promise()
35+
})
3836
}
39-
40-
return Promise.resolve()
37+
return 0
4138
}
4239

4340
// split a CSV to multiple files and trigger lambdas
@@ -128,7 +125,6 @@ function split({
128125
newStream.on('error', (e) => cb(e))
129126

130127
return newStream.on('end', () => {
131-
const limit = pLimit(3) //set concurrent call to 3 at a time
132128
// write the last records
133129
if (lineCounter > 0) {
134130
fileCounter += 1
@@ -158,16 +154,13 @@ function split({
158154
`${extra} extra (Files ${startFile}-${maxEndFile})`
159155
)
160156

161-
const promises = lodash.range(numLambdas).map((i) => limit(() => {
162-
endFile = (i < extra) ? startFile + batchSize : (startFile + batchSize) - 1
157+
for (let i = 0; i < numLambdas; i += 1) {
158+
endFile = (i < extra) ? (startFile + batchSize) : ((startFile + batchSize) - 1)
159+
invokeLambda(bucket, key, startFile, Math.min(endFile, maxEndFile), arn)
163160
startFile = endFile + 1
164-
return invokeLambda(bucket, key, startFile - 1, Math.min(endFile, maxEndFile), arn)
165-
}))
166-
167-
return Promise.all(promises).then(() => cb()).catch(cb)
161+
}
168162
}
169163
cb()
170-
return Promise.resolve()
171164
})
172165
}
173166

packages/api-lib/libs/queries.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const geometryQuery = (field, geometry) => {
8787

8888

8989
const intersects = (inGeojson, queries) => {
90-
let geojson
90+
let geojson = inGeojson
9191
// if we receive an object, assume it's GeoJSON, if not, try and parse
9292
if (typeof geojson === 'string') {
9393
try {

0 commit comments

Comments
 (0)