Skip to content
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
74dde50
GPII-3138: Added CouchDB views for retrieving snapset data.
cindyli Jun 27, 2018
ee30bb2
GPII-3138: Update snapsets in the data base
klown Jul 6, 2018
1c0f38a
GPII-3138: Update snapsets in the data base
klown Jul 6, 2018
b5dd8c0
GPII-3138: Update snapsets in the data base
klown Jul 6, 2018
f7068c0
GPII-3138: Update snapsets in the data base
klown Jul 9, 2018
e2f4e63
GPII-3138: Update snapsets in the data base
klown Jul 9, 2018
554ae82
GPII-3138: Update snapsets in the data base
klown Jul 9, 2018
f145f66
GPII-3138: Delete and reload snapsets in the data base
klown Jul 10, 2018
8f54a33
GPII-3138: Merged upstream master GPII branch into GPII-3138
klown Jul 16, 2018
67f7bd6
GPII-3138: Add a couchDB view to return all GPII keys.
cindyli Jul 18, 2018
c48d7ae
Merge pull request #1 from cindyli/GPII-3138
klown Jul 18, 2018
f029df2
GPII-3138: Merged Cindy's pull request with new database view
klown Jul 18, 2018
5f2f1b5
GPII-3138: Delete and (re)load snapsets into the database
klown Jul 20, 2018
750cdf3
GPII-3138: Delete and reload snapsets into the database
klown Jul 23, 2018
0e41600
GPII-3138: Delete and reload snapsets into the database
klown Jul 24, 2018
22d6605
GPII-3138: Delete and load snapsets Prefs Safes.
klown Jul 25, 2018
574236f
GPII-3138: Delete and load snapsets Prefs Safes into the database.
klown Jul 25, 2018
d6547d3
GPII-3138: Delete and load snapsets Prefs Safes into the database.
klown Jul 25, 2018
8520379
GPII-3138: Delete and load snapsets into the database
klown Jul 25, 2018
ef1e721
GPII-3138: Merged upstream GPII master branch.
klown Jul 26, 2018
0181c42
GPII-3138: Delete and load snapsets into the database
klown Jul 27, 2018
9bb64af
GPII-3138: Update snapsets into the database
klown Jul 30, 2018
a4541ba
GPII-3138: Update snapsets into the database
klown Jul 30, 2018
e026465
GPII-3138: Merged changes from upstreasm master GPII branch.
klown Jul 31, 2018
f4c41a6
GPII-3138: Update snapsets into the database
klown Jul 31, 2018
6723b6e
GPII-3138: Update snapsets into the database
klown Jul 31, 2018
2e0bb55
GPII-3138: Update snapsets into the database
klown Jul 31, 2018
fae02da
GPII-3138: Use UUIDs for demo user keys as well as creating 20 empty …
cindyli Aug 1, 2018
831a762
Merge pull request #2 from cindyli/GPII-3138
klown Aug 1, 2018
582b3d7
GPII-3138: Update snapsets in the database
klown Aug 5, 2018
c401c97
GPII-3138: Update snapsets in the database
klown Aug 7, 2018
54defe7
GPII-3138: Update snapsets in the database
klown Aug 7, 2018
58fdde7
GPII-3138: Update snapsets in the database
klown Aug 9, 2018
0862af6
GPII-3138: Merged changes from upstream master GPII branch.
klown Aug 10, 2018
79abd7d
GPII-3138: Merged changes from upstream master GPII branch
klown Aug 27, 2018
2b8cbeb
GPII-3138: Update snapsets in the database
klown Aug 28, 2018
59f03a8
GPII-3138: Update snapsets in the database
klown Aug 30, 2018
6ee716e
GPII-3138: Update snapsets in the database
klown Sep 10, 2018
9a090a1
GPII-3138: Update snapsets in the database
klown Sep 11, 2018
a9eec11
GPII-3138: Update snapsets in the database
klown Sep 11, 2018
a4cf452
GPII-3138: Update snapsets in the database
klown Sep 12, 2018
63c1a11
GPII-3138: Update snapsets in the database
klown Sep 13, 2018
7ce1b84
GPII-3138: Update snapsets in the database
klown Sep 18, 2018
afc6888
GPII-3138: Update snapsets in the database
klown Sep 19, 2018
75456ba
GPII-3138: Update snapsets in the database
klown Sep 19, 2018
230c8f0
GPII-3138: Update snapsets in the database
klown Sep 19, 2018
23b27e4
GPII-3138 Merged upstream master GPII branch
klown Oct 9, 2018
33f1741
GPII-3138: Update snapsets in the database.
klown Oct 9, 2018
2c48ca5
GPII-3138: Update snapsets in the database
klown Oct 11, 2018
d9ac25e
GPII-3138: Update snapsets in the database
klown Oct 15, 2018
ebde69d
GPII-3138: Update snapsets in the database
klown Oct 17, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,22 @@ have set the `NODE_ENV` variable.

### Convert Preferences Data

GPII has 2 set of preferences JSON5 data files:

* The preferences files for running GPII are located at %gpii-universal/testData/preferences
* The preferences files for running node tests are located at %gpii-universal/tests/data/preferences

When any preferences file in either one of these 2 directories are modified, running `npm run postinstall` will generate
GPII has two sets of preferences JSON5 data files, located at `%gpii-universal/testData/preferences` and `%gpii-universal/tests/data/preferences`:

* The preferences files for running GPII and for integration tests are located at
`%gpii-universal/testData/preferences`. These files are converted into two types of preferences safes and GPII keys:
* They are converted into `snapset` preferences safes and GPII keys and placed into the
`%gpii-universal/build/dbData/snapset/` folder. These are used to update the snapsets in CouchDB when GPII is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading "when GPII is run in a production or staging configuration" reminds me the use of config files in gpii/configs directory. All those configs use pouchDB at the backend.

Probably adjust this sentence to express datasets in this folder are:

  1. loaded into the production and staging CouchDB in the real clouds.
  2. loaded into the pouchDB when GPII runs locally (regardless which config is used.).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cindyli I've reworked the whole section to:

  1. better sync up with the testData\dbData\README.txt, and
  2. adjust the wording to reflect your suggestions.

run in a production or staging configuration.
* They are also converted into `user` preferences safes and GPII keys and placed into the
`%gpii-universal/build/dbData/user/` folder. These are used with PouchDB when GPII runs in a development
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When GPII runs in a development configuration, it also uses snapset-type data from %gpii-universal/build/dbData/snapset/. See pouchManager code.

%gpii-universal/build/dbData/user/ is only used for running integration tests. See PouchTestCaseHolder.

The doc in testData/dbData/README.txt for these data sets are correct. Please sync up. Thanks.

configuration or when running GPII integration tests.
* The preferences files for running node tests are located at `%gpii-universal/tests/data/preferences`. These files
are converted into preferences safes and GPII keys:
* They are converted into `user` preferences safes and GPII keys and placed into the
`%gpii-universal/build/tests/dbData/user` folder. These are used during testing with PouchDB.

When any preferences file in either one of these two directories are modified, running `npm run postinstall` will generate
gpiiKeys.json and prefsSafes.json, the files that are in the structure to be loaded into PouchDB/CouchDB, based off
these directories. This step is needed for the modification to be applied to GPII.

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gpii/node_modules/testing/src/PouchTestCaseHolder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@
"test:vagrantProduction": "vagrant ssh -c 'cd /home/vagrant/sync/universal; DISPLAY=:0; ./scripts/vagrantCloudBasedContainers.sh'",
"posttest": "node node_modules/nyc/bin/nyc.js report -r text-summary -r html --report-dir reports --temp-directory coverage",
"start": "node gpii.js",
"postinstall": "node scripts/browserifyTestDependency.js && node scripts/convertPrefs.js testData/preferences/ build/dbData/ && node scripts/convertPrefs.js tests/data/preferences/ build/tests/dbData/"
"postinstall": "node scripts/browserifyTestDependency.js && node scripts/convertPrefs.js testData/preferences/ build/dbData/snapset/ snapset && node scripts/convertPrefs.js testData/preferences/ build/dbData/user/ user && node scripts/convertPrefs.js tests/data/preferences/ build/tests/dbData/ user"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this README section to add which set of data are converted to what prefs type and why? Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but I'm not sure about everything. Here's what I know and where I'm unclear:

  1. %universal/testData/preferences/ are converted into a set of "snapset" PrefsSafes and their associated GPII keys and placed in the %universal/build/dbData/snapset/ folder. These are used to update the snapset preferences in CouchDB used with a running GPII.
  2. %universal/testData/preferences/ are also converted but into a set of "user" PrefsSafes and GPII keys, and placed in the %universal/build/dbData/user/ folder. I can't remember what these are for.
  3. %universal/tests/data/preferences/ are converted into a set of "user" PrefsSafes and GPII keys and placed in the %universal/build/tests/dbData/ folder. These are used during testing with PouchDB

The main problem is number 2, but am I right about everything else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Number 2 is also for running integration tests with PouchDB. Both data sets from build/dbData/user/ and build/tests/dbData are loaded by [PouchTestCaseHolder|https://github.com//pull/626/files#diff-9a09cbe02e1a616b46e9ff110b1b1452R48].

}
}
14 changes: 10 additions & 4 deletions scripts/convertPrefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt
// This script reads files from an input directory that contains preferences JSON5 files and convert them to JSON files of GPII keys and
// preferences safes suitable for direct loading into CouchDB or PouchDB, which comply with the new GPII data model:
// https://wiki.gpii.net/w/Keys,_KeyTokens,_and_Preferences in the target directory
// Usage: node scripts/convertPrefs.js {input_path} {target_path}
// Usage: node scripts/convertPrefs.js {input_path} {target_path} {prefsSafeType}, where {prefsSafeType} is one of "snapset" or "user" and defaults to "user"
//
// A sample command that runs this script in the universal root directory:
// node scripts/convertPrefs.js testData/preferences/ build/dbData/
// node scripts/convertPrefs.js testData/preferences/ build/dbData/ snapset

"use strict";

Expand All @@ -25,13 +25,19 @@ var fs = require("fs"),

var inputDir = process.argv[2];
var targetDir = process.argv[3];
var prefsSafeType = process.argv[4] || "user";

if (prefsSafeType !== "snapset" && prefsSafeType !== "user") {
console.log("Usage: node scripts/convertPrefs.js InputFolder OutputFolder PrefsSafeType");
console.log(" where PrefsSafeType, is one of 'snapset' or 'user' (defaults to 'user')");
process.exit(1);
}
var prefsSafes = [];
var gpiiKeys = [];

var filenames = fs.readdirSync(inputDir);

console.log("Converting preferences data in the source directory " + inputDir + " to the target directory " + targetDir + " ...");
console.log("Converting preferences data in the source directory " + inputDir + " to the target directory " + targetDir + " as " + prefsSafeType + " Prefs Safes ...");

// Read and loop thru json5 files in the input directory
rimraf(targetDir, function () {
Expand Down Expand Up @@ -60,7 +66,7 @@ rimraf(targetDir, function () {
"_id": prefsSafeId,
"type": "prefsSafe",
"schemaVersion": "0.1",
"prefsSafeType": "user",
"prefsSafeType": prefsSafeType,
"name": gpiiKey,
"password": null,
"email": null,
Expand Down
Loading