-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from developmentseed/enhance/photo-to-osm-element
Set one-to-many relation between photos and OSM elements (and other changes)
- Loading branch information
Showing
20 changed files
with
136 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import nanoid from 'nanoid'; | ||
import config from 'config'; | ||
import generate from 'nanoid/generate'; | ||
|
||
const idLength = config.get('idLength'); | ||
const { length, alphabet } = config.get('elementIds'); | ||
|
||
export function generateId () { | ||
return nanoid(idLength); | ||
return generate(alphabet, length); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
exports.up = function (knex) { | ||
return knex.schema.table('photos', function (t) { | ||
t.dropColumn('osmObjects'); | ||
t.string('osmElement'); | ||
}); | ||
}; | ||
|
||
exports.down = function (knex) { | ||
return knex.schema.table('photos', function (t) { | ||
t.dropColumn('osmElement'); | ||
t.specificType('osmObjects', 'text[]'); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Enable ECMAScript module loader | ||
require = require("esm")(module); // eslint-disable-line | ||
|
||
const { createMockUser } = require('../test/utils/mock-factory'); | ||
|
||
exports.seed = async function (knex) { | ||
console.log('Seeding users...') // eslint-disable-line | ||
|
||
// Create 5 admins | ||
for (let i = 0; i < 5; i++) { | ||
await createMockUser({ isAdmin: true }); | ||
} | ||
|
||
// Create more 45 users | ||
for (let i = 0; i < 45; i++) { | ||
await createMockUser(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Enable ECMAScript module loader | ||
require = require("esm")(module); // eslint-disable-line | ||
|
||
const { createMockPhoto, getRandomInt } = require('../test/utils/mock-factory'); | ||
|
||
exports.seed = async function (knex) { | ||
console.log('Seeding photos...') // eslint-disable-line | ||
|
||
const users = await knex('users').select('osmId'); | ||
|
||
const totalUsers = users.length; | ||
|
||
if (users.length === 0) { | ||
throw Error('No users found. Please login to create a user to associate mock data.'); | ||
} | ||
|
||
for (let i = 0; i < 50; i++) { | ||
const user = users[getRandomInt(totalUsers)]; | ||
await createMockPhoto({ osmId: user.osmId }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Enable ECMAScript module loader | ||
require = require("esm")(module); // eslint-disable-line | ||
|
||
const { createMockTrace, getRandomInt } = require('../test/utils/mock-factory'); | ||
|
||
exports.seed = async function (knex) { | ||
console.log('Seeding traces...') // eslint-disable-line | ||
|
||
const users = await knex('users').select('osmId'); | ||
|
||
const totalUsers = users.length; | ||
|
||
if (users.length === 0) { | ||
throw Error('No users found. Please login to create a user to associate mock data.'); | ||
} | ||
|
||
for (let i = 0; i < 50; i++) { | ||
const user = users[getRandomInt(totalUsers)]; | ||
await createMockTrace({ osmId: user.osmId }); | ||
} | ||
}; |
Oops, something went wrong.