Skip to content

Commit

Permalink
Merge pull request #318 from SlateFoundation/develop
Browse files Browse the repository at this point in the history
Release: v2.17.2
  • Loading branch information
themightychris authored Jan 11, 2022
2 parents 8a12bc3 + 01eac77 commit f2fd0d1
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .holo/sources/skeleton-v2.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[holosource]
url = "https://github.com/JarvusInnovations/emergence-skeleton-v2"
ref = "refs/tags/v2.8.11"
ref = "refs/tags/v2.8.13"
109 changes: 109 additions & 0 deletions docs/operations/data-loading/contacts-spreadsheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Contacts Spreadsheet

## Initialize git branch

Initialize a new git repository if needed, or just `cd` into an existing one:

```bash
git init myschool-slate
cd myschool-slate
```

Then check out a fresh branch to track content import content:

```bash
git checkout --orphan gitsheets/imports/contacts
```

Declare a new gitsheet to store contact data by creating this file:

=== ".gitsheets/student-contacts.toml"

```toml
[gitsheet]
root = "student-contacts"
path = "${{ '{{' }} student.username }}"

[gitsheet.fields.student]
default = {}
```

Finally, stage and commit the gitsheet declaration:

```bash
git add .gitsheets/student-contacts.toml
git commit -m "feat: define student-contacts gitsheet"
```

## Spreadsheet template

Populate this template with student and relationship contact details:

```csv
student.name,student.username,student.number,student.email.personal,student.phone.home,student.phone.mobile,guardian1.name,guardian1.relationship,guardian1.email.personal,guardian1.phone.home,guardian1.phone.mobile,guardian1.phone.work,guardian2.name,guardian2.relationship,guardian2.email.personal,guardian2.phone.home,guardian2.phone.mobile,guardian2.phone.work
John Doe,johndoe7,,[email protected],,267-111-1234,Michael Doe,Father,[email protected],,267-222-1234,394-231-3245,Jane Doe,Mother,[email protected],,267-384-2835,325-234-3818
```

## Load spreadsheet into gitsheet

Use the `git sheet upsert` command to load the filled CSV from the previous template:

```bash
git sheet upsert \
--delete-missing \
"student-contacts" \
~/Downloads/myschool_contacts.csv
```

And then commit the resulting staged records:

```bash
git commit -m "data: load student contacts from spreadsheet"
```

## Review relationship labels

Use this command to analyze all the relationship labels used in this dataset:

```bash
git sheet query student-contacts \
| jq '[ .[].guardian1.relationship, .[].guardian2.relationship ] | unique'
```

If any strange values or abbreviations are present, consider using find/replace on the original spreadsheet to normalize this with some more standard values, and then repeat the load step above to add a commit with your changes.

## Extract data from Slate instance into gitsheet

Install the `slate-gitsheets` command if needed:

```bash
npm install -g slate-gitsheets
```

Download users from Slate into another branch:

```bash
slate-gitsheets extract-slate \
--ref=gitsheets/slate \
--host=https://myschool.org/ \
--host-name=myschool
```

## Merge spreadsheet data into Slate data

Merge data from the `student-contacts` gitsheet into the Slate `users` gitsheet:

```bash
slate-gitsheets merge-contacts \
--contacts-ref=gitsheets/imports/contacts \
--slate-ref=gitsheets/slate
```

## Load data from gitsheets into Slate instance

```bash
slate-gitsheets load-slate \
--ref=gitsheets/slate \
--host=https://myschool.org/ \
--host-name=myschool
```
7 changes: 7 additions & 0 deletions php-classes/Emergence/People/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ class Relationship extends \VersionedRecord
'InverseRelationship'
];

public static $validators = [
'Label' => [
'required' => true,
'errorMessage' => 'A label is required'
]
];


public function validate($deep = true)
{
Expand Down
57 changes: 57 additions & 0 deletions script/-test-bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

# script/-test-bootstrap: Check dependencies for testing.

set -e
cd "$(dirname "$0")/.."


echo
echo "==> studio-bootstrap: verifying hologit"

if ! [ -x "$(command -v git-holo)" ]; then
echo "Please install git-holo command with npm: npm install -g hologit"
echo "Or with Habitat: hab pkg install --binlink jarvus/hologit"
exit 1
fi


echo
echo "==> bootstrap: verifying Node.js…"

if ! [ -x "$(command -v node)" ]; then
echo
echo " Please install Node.js: https://nodejs.org/en/download/"
exit 1
fi

node_version="$(node --version)"
echo " Found node version: ${node_version}"
if ! [[ $node_version =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo
echo " Could not parse node version: ${node_version}"
echo " Please install node v14.x"
exit 1
fi

# check that node >= MAJOR.MINOR
node_min_major="14"
node_min_minor="15"

IFS='.' read -ra node_version_split <<< "${node_version#v}"
if [ "${node_version_split[0]}" -lt "${node_min_major}" ] || [[ "${node_version_split[0]}" -le "${node_min_major}" && "${node_version_split[1]}" -lt "${node_min_minor}" ]]; then
echo
echo " Please install Node.js >= ${node_min_major}.${node_min_minor}.x"
echo
exit 1
fi

if ! [ -x "$(command -v npm)" ]; then
echo "Please install the npm command"
exit 1
fi

if ! [ -x "$(command -v npx)" ]; then
echo "Please install the npx command (part of newer npm distributions)"
exit 1
fi
3 changes: 3 additions & 0 deletions script/test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ set -e
cd "$(dirname "$0")/.."


script/-test-bootstrap


temp_path="$(pwd)"
temp_path="${temp_path:1}"
temp_path="${temp_path//\//--}"
Expand Down
3 changes: 3 additions & 0 deletions script/test-interactive
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ set -e
cd "$(dirname "$0")/.."


script/-test-bootstrap


repo_path="$(pwd)"
temp_path="${repo_path}.cypress-workspace"

Expand Down
18 changes: 10 additions & 8 deletions site-root/powertools/user-data-report.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,16 @@ function getRecordsForTable($Person, $tableName, $field = 'PersonID') {

?>

<h2>Data report for <?=htmlspecialchars($Person->FullName)?></h2>
<?php if ($Person) : ?>
<h2>Data report for <?=htmlspecialchars($Person->FullName)?></h2>

<dl>
<?php foreach ($reports as $reportName => $reportFunction) : ?>
<?php $records = $reportFunction($Person) ?>
<dl>
<?php foreach ($reports as $reportName => $reportFunction) : ?>
<?php $records = $reportFunction($Person) ?>

<dt><?=$reportName?></dt>
<dd><?=count($records)?></dd>
<dt><?=$reportName?></dt>
<dd><?=count($records)?></dd>

<?php endforeach ?>
</dl>
<?php endforeach ?>
</dl>
<?php endif ?>

0 comments on commit f2fd0d1

Please sign in to comment.