Skip to content

Commit

Permalink
add option for manual import of camp members (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
OriHoch authored and amotenko committed Mar 4, 2018
1 parent b7c0f0e commit 393aee3
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions docs/development/camps-import.MD
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Importing camps data
# Camps Import and DB manipulations

This method can be used to do the yearly manual import of camps data to spark DB
This method can be used to do the yearly manual import of camps data to spark DB and manual fixes / adjustments as required.

## Input Data

## Initial Camps Import

### Input Data

The input data is an excel or google sheet with the following columns:

Expand All @@ -11,7 +14,7 @@ The input data is an excel or google sheet with the following columns:
* camp_leader_name
* camp_leader_email

## import process
### import process

* login to adminer, create a new table for this event's camps data
* **set collation to UTF-8**
Expand Down Expand Up @@ -53,10 +56,14 @@ update camps set status='open' where event_id='MIDBURN2018';

## Importing additional camps

* edit `camps_2018` table and add `import_group` column with default value of `1`
* prepare import csv file for the additional camps with the additional `import_group` column with value of `2`
After the initial import you can add additional camps using an `import_group` column and incrementing the group number on each additional import

* for the first additional import - edit `camps_2018` table and add `import_group` column with default value of `1`
* prepare import csv file for the additional camps with the additional `import_group` column with value of max import group + 1 (e.g. `2`)
* import the additional camps using adminer
* continue import process, but add ` and import_group=2` to all where queries of `camps_2018` table:
* continue import process, but add ` and import_group=` to all where queries of `camps_2018` table:

**Replace 2 in following example with the actual latest import_group**

```
update camps_2018 set camp_leader_email=trim(camp_leader_email) where import_group=2;
Expand All @@ -80,3 +87,27 @@ update camps set contact_person_id=main_contact, moop_contact=main_contact, safe
update camps set status='open' where event_id='MIDBURN2018' and camp_name_he in (select camp_name_he from camps_2018 where import_group=2);
```


## Importing additional approved camp members

* You should have a list of approved camp members emails to add to the camp
* All camp members should have a spark / drupal profile
* You can get the relevant camp ID: `select id from camps where camp_name_he like '%%'` and event_id='MIDBURN2018'
* Create a table: `camp_members_2018` with columns: `camp_id,email` (and additional fields if there were in the source data)
* Import the aproved members list to the table
* Trim emails: `update camp_members_2018 set email=trim(email)`
* Update camp members users table camp indication:
```
update users set camp_id=(select camp_id from camp_members_2018 where email = users.email)
where email in (select email from camp_members_2018 where approved_text='מאושרים כחבר מחנה');
```
* Insert camp members (users not already member of 2018 camps)
```
insert into camp_members (camp_id, user_id, status)
select camp_members_2018.camp_id, users.user_id, 'approved'
from camp_members_2018, users
where camp_members_2018.approved_text='מאושרים כחבר מחנה'
and camp_members_2018.email = users.email
and users.user_id not in (select user_id from camp_members where camp_id in (select id from camps where event_id='MIDBURN2018'))
```

0 comments on commit 393aee3

Please sign in to comment.