<commit_before>
#------------------------------------------------------------------------------
#
# GLOBAL SETTINGS
#
# Defines: gateway_schema, dataset_schema, pod_schema, user_schema,
#
#------------------------------------------------------------------------------
import os

# FIGURE OUT WHERE WE ARE RUNNING... ON HEROKU, OR LOCALLY?

if os.environ.get('PORT'):
	# We're hosted on Heroku! Use the MongoHQ Sandbox as our backend
	# Set API entry point (for heroku):
	# Heroku environmental variables must be set using:
	# > heroku config:set key=value
	MONGO_HOST = os.getenv('MONGO_HOST')
	MONGO_PORT = os.getenv('MONGO_PORT')
	MONGO_USERNAME = os.getenv('MONGO_USERNAME')
	MONGO_PASSWORD = os.getenv('<PASSWORD>_PASSWORD')
	MONGO_DBNAME = os.getenv('MONGO_DBNAME')
	SERVER_NAME = os.getenv('SERVER_NAME')
else:
	# Run locally, using a different port than the local gateway app
	MONGO_HOST = 'localhost'
	MONGO_PORT = 27017
	MONGO_DBNAME = 'evepod'
	SERVER_NAME = '0.0.0.0:3000'

# Enable reads (GET), inserts (POST) and DELETE for resources/collections
# (if you omit this line, the API will default to ['GET'] and provide
# read-only access to the endpoint).
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']

# Enable reads (GET), edits (PATCH) and deletes of individual items
# (defaults to read-only item access).
ITEM_METHODS = ['GET', 'PATCH', 'DELETE']

# Set the public methods for the read-only API. 
# Only authorized users can write, edit and delete
# PUBLIC_METHODS = ['GET'] 
# PUBLIC_ITEM_METHODS = ['GET']

#------------------------------------------------------------------------------
#
# RESOURCE SCHEMAS
#
# Defines: 	gateway_schema, dataset_schema, pod_schema, user_schema,
#			allsensorinfo, allpoddata, allfarmerdata, farmers 
#
#------------------------------------------------------------------------------
gateway_schema = {
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	'urlid' : {
		'type': 'string',
		'minlength': 1,
		'maxlength': 10,
		'required': True,
		'unique': True,
	},
	'pods' : {
		'type':'list','items':[{
			'type':'objectid',
			'data_relation': {
				'resource':'pods',
				'field':'_id',
				'embeddable':True
			}
		},]
	},
}

data_schema = {
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	# Note: using short variable names to save space in MongoDB.
	't':{'type':'datetime','required':True},   # datetime 
	'v':{'type':'float','required':True},      # value
	'p':{'type':'string','required':True},     # pod
	's':{'type':'string','required':True},     # sensor id (SID)
	'pod':{
		'type':'objectid',
		'data_relation': {
			'resource' :'pods',
			'field': '_id',
			'embeddable':True,
		},
	},
	'sensor':{
		'type':'objectid',
		'data_relation': {
			'resource': 'sensors',
			'field': '_id',
			'embeddable': True
		},
	}
}

user_schema = {
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	# Only keys are stored on evepod. All user information is stored on stormpath
	'keys': {'type': 'list','items':[{'type':'string'}]},
}

pod_schema = { 
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	# Sensor text ID for use in URLs and in API data queries/submissions
	'urlid' : { # Pod URL name
		'type': 'string',
		'minlength': 1,
		'maxlength': 20,
		'required': True,
	},
	'pid' : { # Pod ID (usually phone number)
		'type':'string',
		'minlength':10,
		'maxlength':15,
		'required':True,
	},
	'imei':{ # MIEI address of cellular radio, acts as Serial Number
		'type':'string', # Need to define a MAC address type
		'unique':True,
		'required':True,
		'minlength':15,
		'maxlength':15,
	},
	'firmware':{
		'type':'integer',
		'minlength':1,
		'maxlength':1,
	}
}

sensor_schema = { 
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	# Sensor text ID for use in URLs and in API data queries/submissions
	'urlid' : {
		'type': 'string',
		'minlength': 1,<commit_msg>Updated IMEI length to max:20<commit_after>
#------------------------------------------------------------------------------
#
# GLOBAL SETTINGS
#
# Defines: gateway_schema, dataset_schema, pod_schema, user_schema,
#
#------------------------------------------------------------------------------
import os

# FIGURE OUT WHERE WE ARE RUNNING... ON HEROKU, OR LOCALLY?

if os.environ.get('PORT'):
	# We're hosted on Heroku! Use the MongoHQ Sandbox as our backend
	# Set API entry point (for heroku):
	# Heroku environmental variables must be set using:
	# > heroku config:set key=value
	MONGO_HOST = os.getenv('MONGO_HOST')
	MONGO_PORT = os.getenv('MONGO_PORT')
	MONGO_USERNAME = os.getenv('MONGO_USERNAME')
	MONGO_PASSWORD = os.getenv('MONGO_PASSWORD')
	MONGO_DBNAME = os.getenv('MONGO_DBNAME')
	SERVER_NAME = os.getenv('SERVER_NAME')
else:
	# Run locally, using a different port than the local gateway app
	MONGO_HOST = 'localhost'
	MONGO_PORT = 27017
	MONGO_DBNAME = 'evepod'
	SERVER_NAME = '0.0.0.0:3000'

# Enable reads (GET), inserts (POST) and DELETE for resources/collections
# (if you omit this line, the API will default to ['GET'] and provide
# read-only access to the endpoint).
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']

# Enable reads (GET), edits (PATCH) and deletes of individual items
# (defaults to read-only item access).
ITEM_METHODS = ['GET', 'PATCH', 'DELETE']

# Set the public methods for the read-only API. 
# Only authorized users can write, edit and delete
# PUBLIC_METHODS = ['GET'] 
# PUBLIC_ITEM_METHODS = ['GET']

#------------------------------------------------------------------------------
#
# RESOURCE SCHEMAS
#
# Defines: 	gateway_schema, dataset_schema, pod_schema, user_schema,
#			allsensorinfo, allpoddata, allfarmerdata, farmers 
#
#------------------------------------------------------------------------------
gateway_schema = {
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	'urlid' : {
		'type': 'string',
		'minlength': 1,
		'maxlength': 10,
		'required': True,
		'unique': True,
	},
	'pods' : {
		'type':'list','items':[{
			'type':'objectid',
			'data_relation': {
				'resource':'pods',
				'field':'_id',
				'embeddable':True
			}
		},]
	},
}

data_schema = {
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	# Note: using short variable names to save space in MongoDB.
	't':{'type':'datetime','required':True},   # datetime 
	'v':{'type':'float','required':True},      # value
	'p':{'type':'string','required':True},     # pod
	's':{'type':'string','required':True},     # sensor id (SID)
	'pod':{
		'type':'objectid',
		'data_relation': {
			'resource' :'pods',
			'field': '_id',
			'embeddable':True,
		},
	},
	'sensor':{
		'type':'objectid',
		'data_relation': {
			'resource': 'sensors',
			'field': '_id',
			'embeddable': True
		},
	}
}

user_schema = {
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	# Only keys are stored on evepod. All user information is stored on stormpath
	'keys': {'type': 'list','items':[{'type':'string'}]},
}

pod_schema = { 
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	# Sensor text ID for use in URLs and in API data queries/submissions
	'urlid' : { # Pod URL name
		'type': 'string',
		'minlength': 1,
		'maxlength': 20,
		'required': True,
	},
	'pid' : { # Pod ID (usually phone number)
		'type':'string',
		'minlength':10,
		'maxlength':15,
		'required':True,
	},
	'imei':{ # MIEI address of cellular radio, acts as Serial Number
		'type':'string', # Need to define a MAC address type
		'unique':True,
		'required':True,
		'minlength':15,
		'maxlength':20,
	},
	'firmware':{
		'type':'integer',
		'minlength':1,
		'maxlength':1,
	}
}

sensor_schema = { 
	# Schema definition, based on Cerberus grammar. Check the Cerberus project
	# (https://github.com/nicolaiarocci/cerberus) for details.
	# Sensor text ID for use in URLs and in API data queries/submissions
	'urlid' : {
		'type': 'string',
		'minlength': 1,
{'fraction_non_alphanumeric': 0.2173300457907714, 'fraction_numerical': 0.007279558529998826, 'mean_word_length': 3.0736489717838356, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '854890', 'n_tokens_mistral': 3092, 'n_tokens_neox': 2815, 'n_words': 763}