<commit_before>/*
 * Created with IntelliJ IDEA.
 * User: michaelpotter
 * Date: 30/03/15
 * Time: 11:45
 */
package io.github.mvpotter.data.configuration;

import io.github.mvpotter.data.configuration.support.DBProfile;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import javax.sql.DataSource;
import java.net.URI;
import java.net.URISyntaxException;

@Configuration
@Profile(DBProfile.POSTGRES)
public class PostgresConfig {

    public static final String ENV_DATABASE_KEY = "database.url";
    public static final String POSTGRES_DRIVER = "org.postgresql.Driver";

    private static final String URL_FORMAT = "jdbc:postgresql://%s%s";

    @Bean
    public DataSource dataSource() throws URISyntaxException {
        String dbProperty = System.getProperty(ENV_DATABASE_KEY);
        if(dbProperty != null) {
            final URI uri = new URI(dbProperty);
            final String[] credentials = uri.getUserInfo().split(":");
            final String username = credentials[0];
            String password = "";
            if (credentials.length > 1) {
                password = credentials[1];
            }
            final String url = String.format(URL_FORMAT, uri.getHost(), uri.getPath());

            return DataSourceBuilder.create()
                    .driverClassName(POSTGRES_DRIVER)
                    .url(url)
                    .username(username)
                    .password(password)
                    .build();
        }
<commit_msg>Fix issue with getting heroku postgres settings<commit_after>/*
 * Created with IntelliJ IDEA.
 * User: michaelpotter
 * Date: 30/03/15
 * Time: 11:45
 */
package io.github.mvpotter.data.configuration;

import io.github.mvpotter.data.configuration.support.DBProfile;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import javax.sql.DataSource;
import java.net.URI;
import java.net.URISyntaxException;

@Configuration
@Profile(DBProfile.POSTGRES)
public class PostgresConfig {

    public static final String ENV_DATABASE_KEY = "DATABASE_URL";
    public static final String POSTGRES_DRIVER = "org.postgresql.Driver";

    private static final String URL_FORMAT = "jdbc:postgresql://%s:%s%s";

    @Bean
    public DataSource dataSource() throws URISyntaxException {
        String dbProperty = System.getenv(ENV_DATABASE_KEY);
        if(dbProperty != null) {
            final URI uri = new URI(dbProperty);
            final String[] credentials = uri.getUserInfo().split(":");
            final String username = credentials[0];
            String password = "";
            if (credentials.length > 1) {
                password = <PASSWORD>[1];
            }
            final String url = String.format(URL_FORMAT, uri.getHost(), uri.getPort(), uri.getPath());

            return DataSourceBuilder.create()
                    .driverClassName(POSTGRES_DRIVER)
                    .url(url)
                    .username(username)
                    .password(password)
                    .build();
        }

{'fraction_non_alphanumeric': 0.10231316725978648, 'fraction_numerical': 0.00771055753262159, 'mean_word_length': 2.7561247216035634, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 6, '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': '6039117', 'n_tokens_mistral': 944, 'n_tokens_neox': 897, 'n_words': 199}