-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e369188
commit 48b3721
Showing
3 changed files
with
65 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,23 +33,68 @@ o.host="localhost" | |
o.save | ||
``` | ||
|
||
1: Importing massive answers for proposals | ||
------------------------------------------ | ||
Importing massive answers for proposals | ||
--------------------------------------- | ||
|
||
This script answers a list of proposals, it requires an excel with headers with this format: | ||
|
||
``` | ||
ID, status, text_ca, text_es, ... | ||
123, accepted, una resposta, una respuesta, ... | ||
``` | ||
|
||
or | ||
|
||
``` | ||
id, state, answer/ca, answer/es, ... | ||
123, acceptada, una resposta, una respuesta, ... | ||
``` | ||
|
||
> NOTE: | ||
> - Component setting "Publish proposal answers immediately" is honored, so, if activated, emails and notifications will be sent. Otherwise will just introduce the answers in the database. | ||
> - Answers are are parsed to highlight links automatically and convert line breaks to `<br>`; | ||
### Usage: | ||
|
||
Copy the script into your `lib/tasks` of your Decidim installation: | ||
|
||
``` | ||
cd lib/tasks | ||
wget -qO- https://github.com/Platoniq/decidim-scripts/archive/0.2.tar.gz | tar --transform 's/^decidim-scripts-0.2//' -xvz | ||
wget -qO- https://github.com/Platoniq/decidim-scripts/archive/0.3.tar.gz | tar --transform 's/^decidim-scripts-0.3//' -xvz | ||
``` | ||
|
||
Run in local (as testing): | ||
|
||
``` | ||
bin/rails "proposals:batch:answer[[email protected],./pam-ciutat.csv]" | ||
bin/rails "proposals:batch:answer[[email protected],./proposal-answers.csv]" | ||
``` | ||
|
||
Massively geolocating proposals | ||
------------------------------- | ||
|
||
This script geolocates a list of proposals, it requires an excel with headers with this format: | ||
|
||
``` | ||
ID, address, ... | ||
123, some place, ... | ||
``` | ||
|
||
or | ||
|
||
``` | ||
i, adreça, ... | ||
123, some place, ... | ||
``` | ||
|
||
> NOTE: | ||
> - Component setting "Geocoding enabled" is honored, so, if not activated, proposals won't be modified. | ||
``` | ||
bin/rails proposals:batch:geoloc[[email protected],./proposal-geolocs.csv] | ||
``` | ||
|
||
Running in heroku: | ||
------------------ | ||
|
||
In Heroku you need to temporary copy the relevant files into a running container first. | ||
As there's no "copy" command to do that you can use the service https://transfer.sh with this trick: | ||
|
@@ -58,17 +103,15 @@ As there's no "copy" command to do that you can use the service https://transfer | |
1. From your computer, send the files to transfer.sh: | ||
|
||
``` | ||
curl --upload-file pam-ciutat.csv https://transfer.sh/pam-ciutat.csv -H "Max-Days: 1" | ||
curl --upload-file pam-districtes.csv https://transfer.sh/pam-districte.csv -H "Max-Days: 1" | ||
curl --upload-file geolocs.csv https://transfer.sh/geolocs.csv -H "Max-Days: 1" | ||
curl --upload-file proposal-answerss.csv https://transfer.sh/proposal-answers.csv -H "Max-Days: 1" | ||
curl --upload-file proposal-geolocs.csv https://transfer.sh/proposal-geolocs.csv -H "Max-Days: 1" | ||
``` | ||
|
||
Which will return (for instance) the download addresses: | ||
|
||
``` | ||
https://transfer.sh/23lG7/pam-ciutat.csv | ||
https://transfer.sh/YwYAN/pam-districte.csv | ||
https://transfer.sh/x3hUa/geolocs.csv | ||
https://transfer.sh/YwYAN/proposal-answers.csv | ||
https://transfer.sh/x3hUa/proposal-geolocs.csv | ||
``` | ||
|
||
2. Login into a shell session in heroku | ||
|
@@ -80,15 +123,14 @@ heroku run bash | |
3. Download the files inside the dyno: | ||
|
||
``` | ||
wget https://transfer.sh/23lG7/pam-ciutat.csv | ||
wget https://transfer.sh/YwYAN/pam-districte.csv | ||
wget https://transfer.sh/x3hUa/golocs.csv | ||
wget https://transfer.sh/YwYAN/proposal-answers.csv | ||
wget https://transfer.sh/x3hUa/proposal-geolocs.csv | ||
``` | ||
|
||
4. Download the scripts into the `lib/tasks` folder: | ||
|
||
``` | ||
wget -qO- https://github.com/Platoniq/decidim-scripts/archive/0.2.tar.gz | tar --transform 's/^decidim-scripts-0.2//' -xvz -C lib/tasks | ||
wget -qO- https://github.com/Platoniq/decidim-scripts/archive/0.3.tar.gz | tar --transform 's/^decidim-scripts-0.3//' -xvz -C lib/tasks | ||
``` | ||
|
||
5. Run the script inside the shell session (2nd terminal): | ||
|
@@ -101,9 +143,8 @@ bin/rails proposals:batch:geoloc | |
or: | ||
|
||
``` | ||
bin/rails proposals:batch:answer[[email protected],./pam-ciutat.csv] | ||
bin/rails proposals:batch:answer[[email protected],./pam-districtes.csv] | ||
bin/rails proposals:batch:geoloc[[email protected],./geolocs.csv] | ||
bin/rails proposals:batch:answer[[email protected],./proposal-answerss.csv] | ||
bin/rails proposals:batch:geoloc[[email protected],./proposal-geolocs.csv] | ||
``` | ||
|
||
NOTE: in case the program runs out of memory in Redis, just execute it again after a minute or so to allow for the queue to empty. |
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