<commit_before># AskUp: POC single app
## Question Market incorporated into AskUp

This is proof of concept code that brings the underlying data into AskUp 
(removing dependency on Question Market). To get it running, you'll need to get
your AskUp database set up like your Question Market database; basically, you'll 
need to run migrations, and then optionally copy data from your Question Market 
question_groups, questions, and answers tables if you don't want to start over.
 
1. It's a good idea to make a backup of your development.sqlite3 file, e.g.:
          
          cp db/development.sqlite3 db/development-backup.sqlite3

2. Run migrations. (This is needed to add the question groups table to AskUp.)

          bundle exec rake db:migrate

3. _(optional)_ Dump your questions, answers, and question groups from your
Question Market (QM) database into your AskUp (AU) database.
    * Open the *QM database* in the sqlite3 shell, then dump the tables.
  
            sqlite3 db/development.sqlite3   # in question-market
            .output qm_questions_dump.txt
            .dump questions
    
    * Drop the old table *in AU* and reload it with the dump files.
  
            sqlite3 db/development.sqlite3   # in askup
            drop questions
            .read qm_questions_dump.txt   # from question-market dir/project<commit_msg>combines existing AU setup documentation (albeit still sketchy) with upgrade info<commit_after># AskUp

AskUp is an application designed to improve learning and retention.

## Configuration

### Ruby, rails
* App has been developed thus far using Ruby 2.1.4 and Rails 4.2.0

### Settings files
* Create .yml versions of all config/*.yml.example files
* generate secret keys (see secrets.yml.example)
** `rake secret | pbcopy` (or equivalent) and put the secret key into secure ENV variable (e.g. `export ASKUP_SECRET_KEY_BASE=...`)

### Database
* install postgres
* run postgres (set up agent, or run manually)
* rake db:create:all
* rake db:migrate -- or use taps gem if required to pull records from another (e.g. sqlite3) db

### Devise (user authentication)
* [Devise setup](https://github.com/plataformatec/devise#getting-started)

### Static assets
* If using in production, set up static assets served from e.g. nginx / apache

# Upgrading from Question Market backend

If you want to bring your data from Question Market into AskUp, you'll need to get
your AskUp database set up like your Question Market database; basically, you'll 
need to run migrations, and then optionally copy data from your Question Market 
question_groups, questions, and answers tables if you don't want to start over.
 
1. It's a good idea to make a backup of your development.sqlite3 file, e.g.:
          
          cp db/development.sqlite3 db/development-backup.sqlite3

2. Run migrations. (This is needed to add the question groups table to AskUp.)

          bundle exec rake db:migrate

3. _(optional)_ Dump your questions, answers, and question groups from your
Question Market (QM) database into your AskUp (AU) database.
    * Open the *QM database* in the sqlite3 shell, then dump the tables.
  
            sqlite3 db/development.sqlite3   # in question-market
            .output qm_questions_dump.txt
            .dump questions
    
    * Drop the old table *in AU* and reload it with the dump files.
  
            sqlite3 db/development.sqlite3   # in askup
            drop questions
            .read qm_questions_dump.txt   # from question-market dir/project
{'fraction_non_alphanumeric': 0.06513083048919227, 'fraction_numerical': 0.008248009101251423, 'mean_word_length': 3.162130177514793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3448284', 'n_tokens_mistral': 989, 'n_tokens_neox': 950, 'n_words': 445}