Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wattsworth
/
lumen-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b8fe0d96
authored
Aug 03, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added local environment with bootstrap rake task
parent
dcc312e4
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
140 additions
and
6 deletions
app/services/db/update_db.rb
app/services/db_stream/update_stream.rb
config/database.yml
config/environments/local.rb
config/environments/production.rb
config/secrets.yml
db/seeds.rb
lib/tasks/local.rake
app/services/db/update_db.rb
View file @
b8fe0d96
...
@@ -28,13 +28,15 @@ class UpdateDb
...
@@ -28,13 +28,15 @@ class UpdateDb
entries
=
__create_entries
(
schema
)
entries
=
__create_entries
(
schema
)
updater
=
UpdateFolder
.
new
(
@root_folder
,
entries
)
updater
=
UpdateFolder
.
new
(
@root_folder
,
entries
)
# update db attributes from dbinfo
# update db attributes from dbinfo
@db
.
size_total
=
dbinfo
[
:size_total
]
@db
.
size_total
=
dbinfo
[
:size_total
]
@db
.
size_db
=
dbinfo
[
:size_db
]
@db
.
size_db
=
dbinfo
[
:size_db
]
@db
.
size_other
=
dbinfo
[
:size_other
]
@db
.
size_other
=
dbinfo
[
:size_other
]
@db
.
version
=
dbinfo
[
:version
]
@db
.
version
=
dbinfo
[
:version
]
absorb_status
(
updater
.
run
)
#@root_folder.transaction do
absorb_status
(
updater
.
run
)
#end
@db
.
save
@db
.
save
set_notice
(
"Database refreshed"
)
set_notice
(
"Database refreshed"
)
self
self
...
...
app/services/db_stream/update_stream.rb
View file @
b8fe0d96
...
@@ -51,7 +51,7 @@ class UpdateStream
...
@@ -51,7 +51,7 @@ class UpdateStream
# specified DbStream
# specified DbStream
def
__build_decimations
(
stream
:,
entry_group
:)
def
__build_decimations
(
stream
:,
entry_group
:)
if
!
entry_group
.
empty?
if
!
entry_group
.
empty?
Rails
.
logger
.
warn
(
"deleting decimations for
#{
stream
.
path
}
"
)
Rails
.
logger
.
debug
(
"deleting decimations for
#{
stream
.
path
}
"
)
stream
.
db_decimations
.
destroy_all
#remove existing decimations
stream
.
db_decimations
.
destroy_all
#remove existing decimations
end
end
entry_group
.
each
do
|
entry
|
entry_group
.
each
do
|
entry
|
...
...
config/database.yml
View file @
b8fe0d96
...
@@ -14,6 +14,11 @@ development:
...
@@ -14,6 +14,11 @@ development:
database
:
db/development.sqlite3
database
:
db/development.sqlite3
timeout
:
10000
timeout
:
10000
local
:
<<
:
*default
database
:
db/local.sqlite3
timeout
:
10000
# Warning: The database defined as "test" will be erased and
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
# Do not set this db to the same as development or production.
...
...
config/environments/local.rb
0 → 100644
View file @
b8fe0d96
Rails
.
application
.
configure
do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config
.
cache_classes
=
true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config
.
eager_load
=
true
# Full error reports are disabled and caching is turned on.
config
.
consider_all_requests_local
=
false
config
.
action_controller
.
perform_caching
=
true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config
.
public_file_server
.
enabled
=
ENV
[
'RAILS_SERVE_STATIC_FILES'
].
present?
# Compress JavaScripts and CSS.
config
.
assets
.
js_compressor
=
:uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config
.
assets
.
compile
=
false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config
.
force_ssl
=
false
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config
.
log_level
=
:info
# Prepend all log lines with the following tags.
config
.
log_tags
=
[
:request_id
]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "control_panel_#{Rails.env}"
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config
.
i18n
.
fallbacks
=
true
# Send deprecation notices to registered listeners.
config
.
active_support
.
deprecation
=
:notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config
.
log_formatter
=
::
Logger
::
Formatter
.
new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if
ENV
[
"RAILS_LOG_TO_STDOUT"
].
present?
logger
=
ActiveSupport
::
Logger
.
new
(
STDOUT
)
logger
.
formatter
=
config
.
log_formatter
config
.
logger
=
ActiveSupport
::
TaggedLogging
.
new
(
logger
)
end
# Do not dump schema after migrations.
config
.
active_record
.
dump_schema_after_migration
=
false
end
config/environments/production.rb
View file @
b8fe0d96
...
@@ -44,7 +44,7 @@ Rails.application.configure do
...
@@ -44,7 +44,7 @@ Rails.application.configure do
# Use the lowest log level to ensure availability of diagnostic information
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
# when problems arise.
config
.
log_level
=
:
debug
config
.
log_level
=
:
info
# Prepend all log lines with the following tags.
# Prepend all log lines with the following tags.
config
.
log_tags
=
[
:request_id
]
config
.
log_tags
=
[
:request_id
]
...
...
config/secrets.yml
View file @
b8fe0d96
...
@@ -19,7 +19,8 @@
...
@@ -19,7 +19,8 @@
development
:
development
:
secret_key_base
:
5378da95ac37be4d4bab4010596a835b639e01dd084ea37e151bf05fc5dec0c6f46f1b162e9325121d757a4683df9880819ba269f488f93a647c935f9b1453d0
secret_key_base
:
5378da95ac37be4d4bab4010596a835b639e01dd084ea37e151bf05fc5dec0c6f46f1b162e9325121d757a4683df9880819ba269f488f93a647c935f9b1453d0
local
:
secret_key_base
:
7c6333cf4833d556c050d005c198903bd5af6377ab706d92c03089ca9a42b3573ec7e5d30f7590214c29775438483fbf82cc12dae5f1cf396441b28fc1d64e81
test
:
test
:
secret_key_base
:
4bb907a33b2b802d006591923f59fa1d0c355f0005dea53efee24b842b17b6b2addd264b20d2d51283c7a0d291efe6888cd1c7e1959f07ccb56304a713696b1e
secret_key_base
:
4bb907a33b2b802d006591923f59fa1d0c355f0005dea53efee24b842b17b6b2addd264b20d2d51283c7a0d291efe6888cd1c7e1959f07ccb56304a713696b1e
...
...
db/seeds.rb
View file @
b8fe0d96
...
@@ -16,7 +16,7 @@ DatabaseCleaner.clean
...
@@ -16,7 +16,7 @@ DatabaseCleaner.clean
# create named users
# create named users
def
create_user
(
first_name
,
last_name
)
def
create_user
(
first_name
,
last_name
)
FactoryGirl
.
create
(
:
confirmed_
user
,
FactoryGirl
.
create
(
:user
,
first_name:
first_name
,
first_name:
first_name
,
last_name:
last_name
)
last_name:
last_name
)
end
end
...
...
lib/tasks/local.rake
0 → 100644
View file @
b8fe0d96
require
'factory_girl_rails'
ADMIN_NAME
=
"admin"
ADMIN_PASSWORD
=
"password"
ADMIN_EMAIL
=
"admin@wattsworth.local"
namespace
:local
do
desc
"Setup and standalone systems running Lumen API"
task
:bootstrap
=>
:environment
do
# Create an admin user"
@admin
=
User
.
find_by_email
(
ADMIN_EMAIL
)
if
(
@admin
.
nil?
)
puts
'Creating new admin user'
@admin
=
FactoryGirl
.
create
(
:user
,
first_name:
'John'
,
last_name:
'Doe'
,
password:
ADMIN_PASSWORD
,
password_confirmation:
ADMIN_PASSWORD
,
email:
ADMIN_EMAIL
)
end
@installation
=
Nilm
.
find_by_url
(
"http://localhost/nilmdb"
)
if
(
@installation
.
nil?
)
puts
'Creating new local installation'
#create a local installation
nilm_creator
=
CreateNilm
.
new
nilm_creator
.
run
(
name:
'local'
,
description:
'local database'
,
url:
'http://localhost/nilmdb'
,
owner:
@admin
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment