<commit_before>Deployment
==========

Install required python packages:

```
$ pip install -r requirements/production.txt
```

or

```
$ pip install -r requirements.txt
```

Note: PyLucene requires manual installation.

Persistence
-----------

For the storage engine, the following software is tested:
- PostgreSQL 9.1 or higher (you must create filmyou database)
- Apache Cassandra 2.0.5 or higher
- Apache Lucene 4.6 or higher

Configure the environment variables:
- RDBMS_USER: PostgreSQL user login
- RDBMS_PASSWORD: PostgreSQL user password
- RDBMS_HOST: PostgreSQL IP address
- RDBMS_PORT: PostgreSQL port
- CASSANDRA_HOST: Cassandra IP address
- CASSANDRA_PORT: Cassandra port
- CASSANDRA_KEYSPACE: Cassandra keyspace
- LUCENE_PATH: Path to Lucene index


### PostgreSQL Schema

After creating `filmyou` database, run the following commands to initialise tables and indexes:

```
$ python manage.py syncdb
$ python manage.py migrate
$ python manage.py check_permissions
```

Add some default properties:

```
ALTER TABLE films_film ALTER COLUMN n_votes SET DEFAULT 0;
ALTER TABLE films_film ALTER COLUMN sum_votes SET DEFAULT 0.0;
```

#### Autocompletion Optimization

Add GIN indexes to speed up ILIKE queries:

```
CREATE EXTENSION pg_trgm;
CREATE INDEX "films_person_name_gin" ON "films_person" USING GIN ("name");
CREATE INDEX "films_genre_name_gin" ON "films_genre" USING GIN ("name");
CREATE INDEX "films_country_name_gin" ON "films_country" USING GIN ("name");
CREATE INDEX "films_language_name_gin" ON "films_language" USING GIN ("name");
```

We need to change Django ORM behaviour:
- Replace 'LIKE UPPER(%s)' with 'ILIKE %s' and `UPPER(%s)` with `ILIKE %s` in `/path/to/site-packages/django/db/backends/postgresql_psycopg2/base.py`.<commit_msg>Set datestyle in PostgreSQL<commit_after>Deployment
==========

Install required python packages:

```
$ pip install -r requirements/production.txt
```

or

```
$ pip install -r requirements.txt
```

Note: PyLucene requires manual installation.

Persistence
-----------

For the storage engine, the following software is tested:
- PostgreSQL 9.1 or higher (you must create filmyou database)
- Apache Cassandra 2.0.5 or higher
- Apache Lucene 4.6 or higher

Configure the environment variables:
- RDBMS_USER: PostgreSQL user login
- RDBMS_PASSWORD: PostgreSQL user password
- RDBMS_HOST: PostgreSQL IP address
- RDBMS_PORT: PostgreSQL port
- CASSANDRA_HOST: Cassandra IP address
- CASSANDRA_PORT: Cassandra port
- CASSANDRA_KEYSPACE: Cassandra keyspace
- LUCENE_PATH: Path to Lucene index


### PostgreSQL Schema

After creating `filmyou` database, run the following commands to initialise tables and indexes:

```
$ python manage.py syncdb
$ python manage.py migrate
$ python manage.py check_permissions
```

Add some default properties:

```
SET datestyle = "ISO, DMY";
ALTER TABLE films_film ALTER COLUMN n_votes SET DEFAULT 0;
ALTER TABLE films_film ALTER COLUMN sum_votes SET DEFAULT 0.0;
```

#### Autocompletion Optimization

Add GIN indexes to speed up ILIKE queries:

```
CREATE EXTENSION pg_trgm;
CREATE INDEX "films_person_name_gin" ON "films_person" USING GIN ("name");
CREATE INDEX "films_genre_name_gin" ON "films_genre" USING GIN ("name");
CREATE INDEX "films_country_name_gin" ON "films_country" USING GIN ("name");
CREATE INDEX "films_language_name_gin" ON "films_language" USING GIN ("name");
```

We need to change Django ORM behaviour:
- Replace 'LIKE UPPER(%s)' with 'ILIKE %s' and `UPPER(%s)` with `ILIKE %s` in `/path/to/site-packages/django/db/backends/postgresql_psycopg2/base.py`.
{'fraction_non_alphanumeric': 0.10341928251121076, 'fraction_numerical': 0.00616591928251121, 'mean_word_length': 5.080068143100511, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '2523380', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1169, 'n_words': 392}