Skip to content

Commit 3c626da

Browse files
authored
Merge pull request #145 from Kpoke/fix/updates
fixes
2 parents a01d9b9 + 29c2eef commit 3c626da

File tree

11 files changed

+122
-0
lines changed

11 files changed

+122
-0
lines changed

__tests__/integration/grower_account/grower_account.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('/grower_account', () => {
2323
about: 'about',
2424
image_url: 'https://www.himage.com',
2525
image_rotation: 44,
26+
show_in_map: true,
2627
};
2728

2829
after(async () => {
@@ -46,6 +47,7 @@ describe('/grower_account', () => {
4647
expect(typeof res.body.reference_id).eql('number');
4748
expect(res.body.organizations.length).to.eql(0);
4849
expect(res.body.images.length).to.eql(0);
50+
expect(res.body.show_in_map).to.eql(false);
4951

5052
const res2 = await request(app)
5153
.post(`/grower_accounts`)
@@ -59,6 +61,7 @@ describe('/grower_account', () => {
5961
expect(typeof res2.body.reference_id).eql('number');
6062
expect(res2.body.organizations.length).to.eql(0);
6163
expect(res2.body.images.length).to.eql(0);
64+
expect(res.body.show_in_map).to.eql(false);
6265
});
6366

6467
it('should not error out if duplicate wallet is sent', async () => {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
var dbm;
4+
var type;
5+
var seed;
6+
var fs = require('fs');
7+
var path = require('path');
8+
var Promise;
9+
10+
/**
11+
* We receive the dbmigrate dependency from dbmigrate initially.
12+
* This enables us to not have to rely on NODE_PATH.
13+
*/
14+
exports.setup = function(options, seedLink) {
15+
dbm = options.dbmigrate;
16+
type = dbm.dataType;
17+
seed = seedLink;
18+
Promise = options.Promise;
19+
};
20+
21+
exports.up = function(db) {
22+
var filePath = path.join(__dirname, 'sqls', '20230501001217-add-token-to-capture-up.sql');
23+
return new Promise( function( resolve, reject ) {
24+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
25+
if (err) return reject(err);
26+
console.log('received data: ' + data);
27+
28+
resolve(data);
29+
});
30+
})
31+
.then(function(data) {
32+
return db.runSql(data);
33+
});
34+
};
35+
36+
exports.down = function(db) {
37+
var filePath = path.join(__dirname, 'sqls', '20230501001217-add-token-to-capture-down.sql');
38+
return new Promise( function( resolve, reject ) {
39+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
40+
if (err) return reject(err);
41+
console.log('received data: ' + data);
42+
43+
resolve(data);
44+
});
45+
})
46+
.then(function(data) {
47+
return db.runSql(data);
48+
});
49+
};
50+
51+
exports._meta = {
52+
"version": 1
53+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
var dbm;
4+
var type;
5+
var seed;
6+
var fs = require('fs');
7+
var path = require('path');
8+
var Promise;
9+
10+
/**
11+
* We receive the dbmigrate dependency from dbmigrate initially.
12+
* This enables us to not have to rely on NODE_PATH.
13+
*/
14+
exports.setup = function(options, seedLink) {
15+
dbm = options.dbmigrate;
16+
type = dbm.dataType;
17+
seed = seedLink;
18+
Promise = options.Promise;
19+
};
20+
21+
exports.up = function(db) {
22+
var filePath = path.join(__dirname, 'sqls', '20230501001718-show-in-map-up.sql');
23+
return new Promise( function( resolve, reject ) {
24+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
25+
if (err) return reject(err);
26+
console.log('received data: ' + data);
27+
28+
resolve(data);
29+
});
30+
})
31+
.then(function(data) {
32+
return db.runSql(data);
33+
});
34+
};
35+
36+
exports.down = function(db) {
37+
var filePath = path.join(__dirname, 'sqls', '20230501001718-show-in-map-down.sql');
38+
return new Promise( function( resolve, reject ) {
39+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
40+
if (err) return reject(err);
41+
console.log('received data: ' + data);
42+
43+
resolve(data);
44+
});
45+
})
46+
.then(function(data) {
47+
return db.runSql(data);
48+
});
49+
};
50+
51+
exports._meta = {
52+
"version": 1
53+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE capture DROP COLUMN token_id;
2+
ALTER TABLE capture DROP COLUMN token_issued;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE capture ADD COLUMN token_id uuid;
2+
ALTER TABLE capture ADD COLUMN token_issued boolean;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE grower_account DROP COLUMN show_in_map;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE grower_account ADD COLUMN show_in_map boolean DEFAULT false;

server/handlers/growerAccountHandler/docs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ const growerAccountComponent = {
137137
phone: { type: 'string' },
138138
about: { type: 'string' },
139139
lat: { type: 'number' },
140+
show_in_map: { type: 'boolean' },
140141
lon: { type: 'number' },
141142
location: { type: 'string' },
142143
image_url: { type: 'string' },

server/handlers/growerAccountHandler/schemas.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const growerAccountGetQuerySchema = Joi.object({
77
id: Joi.string().uuid(),
88
wallet: Joi.string(),
99
bulk_pack_file_name: Joi.string(),
10+
show_in_map: Joi.boolean(),
1011
}).unknown(false);
1112

1213
const growerAccountPostQuerySchema = Joi.object({
@@ -25,6 +26,7 @@ const growerAccountPostQuerySchema = Joi.object({
2526
image_rotation: Joi.number().integer(),
2627
first_registration_at: Joi.date().iso().required(),
2728
bulk_pack_file_name: Joi.string(),
29+
show_in_map: Joi.boolean(),
2830
}).unknown(false);
2931

3032
const growerAccountPatchQuerySchema = Joi.object({
@@ -39,6 +41,7 @@ const growerAccountPatchQuerySchema = Joi.object({
3941
image_rotation: Joi.number().integer(),
4042
status: Joi.string().valid('active', 'deleted'),
4143
gender: Joi.string().valid('male', 'female', 'neutral'),
44+
show_in_map: Joi.boolean(),
4245
}).unknown(false);
4346

4447
const growerAccountIdQuerySchema = Joi.object({

server/models/GrowerAccount.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class GrowerAccount {
3232
bulk_pack_file_name,
3333
created_at,
3434
updated_at,
35+
show_in_map,
3536
}) {
3637
return Object.freeze({
3738
id,
@@ -57,6 +58,7 @@ class GrowerAccount {
5758
bulk_pack_file_name,
5859
created_at,
5960
updated_at,
61+
show_in_map,
6062
});
6163
}
6264

server/repositories/GrowerAccountRepository.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class GrowerAccountRepository extends BaseRepository {
3535
.select(
3636
'grower_account.id',
3737
'grower_account.reference_id',
38+
'grower_account.show_in_map',
3839
'grower_account.wallet',
3940
'grower_account.person_id',
4041
'grower_account.organization_id',

0 commit comments

Comments
 (0)