<commit_before>from rdwgs84 import rdwgs84
import time
import iso8601
import psycopg2
from datetime import datetime
from gtfs_realtime_pb2 import Alert, TripDescriptor, VehiclePosition

conn = psycopg2.connect("dbname='rid2'")
cur = conn.cursor()

"""
Interesting stuff for later:

ScheduleRelationship: SCHEDULED, ADDED, UNSCHEDULED, CANCELED, REPLACEMENT

"""

def getTripJourneyPattern(dataownercode, lineplanningnumber, journeynumber, operatingday):
    print dataownercode, lineplanningnumber, journeynumber, operatingday
    privatecode = ':'.join([dataownercode, lineplanningnumber, str(journeynumber)])

    cur.execute("""SELECT journey.id, journeypatternref FROM journey 
                   LEFT JOIN availabilityconditionday USING (availabilityconditionref)
                   WHERE privatecode = %s and isavailable = true and validdate = %s LIMIT 1;""", (privatecode, operatingday,))

    result = cur.fetchone()

    if result is None:
        return None, None
    else:
        return str(result[0]), str(result[1])

def getFirstStopFromJourneyPattern(journeypatternref):
    cur.execute("""SELECT DISTINCT ON (journeypatternref) pointorder, pointref
                   FROM pointinjourneypattern as p_pt
                   WHERE journeypatternref = %s
                   ORDER BY journeypatternref, pointorder ASC LIMIT 1;""", (journeypatternref,))
<commit_msg>Change databasename<commit_after>from rdwgs84 import rdwgs84
import time
import iso8601
import psycopg2
from datetime import datetime
from gtfs_realtime_pb2 import Alert, TripDescriptor, VehiclePosition

conn = psycopg2.connect("dbname='rid'")
cur = conn.cursor()

"""
Interesting stuff for later:

ScheduleRelationship: SCHEDULED, ADDED, UNSCHEDULED, CANCELED, REPLACEMENT

"""

def getTripJourneyPattern(dataownercode, lineplanningnumber, journeynumber, operatingday):
    print dataownercode, lineplanningnumber, journeynumber, operatingday
    privatecode = ':'.join([dataownercode, lineplanningnumber, str(journeynumber)])

    cur.execute("""SELECT journey.id, journeypatternref FROM journey 
                   LEFT JOIN availabilityconditionday USING (availabilityconditionref)
                   WHERE privatecode = %s and isavailable = true and validdate = %s LIMIT 1;""", (privatecode, operatingday,))

    result = cur.fetchone()

    if result is None:
        return None, None
    else:
        return str(result[0]), str(result[1])

def getFirstStopFromJourneyPattern(journeypatternref):
    cur.execute("""SELECT DISTINCT ON (journeypatternref) pointorder, pointref
                   FROM pointinjourneypattern as p_pt
                   WHERE journeypatternref = %s
                   ORDER BY journeypatternref, pointorder ASC LIMIT 1;""", (journeypatternref,))

{'fraction_non_alphanumeric': 0.08336353751359188, 'fraction_numerical': 0.011235955056179775, 'mean_word_length': 4.036496350364963, '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': '5125754', 'n_tokens_mistral': 860, 'n_tokens_neox': 787, 'n_words': 215}