Coder Social home page Coder Social logo

fablabbcn / smartcitizen-api Goto Github PK

View Code? Open in Web Editor NEW
10.0 19.0 4.0 2.11 MB

The Smart Citizen Engine

Home Page: https://developer.smartcitizen.me

License: GNU Affero General Public License v3.0

Ruby 90.37% HTML 5.69% Shell 3.26% Dockerfile 0.21% JavaScript 0.47%
smartcitizen ruby docker websockets social-sciences environment-sensor sensingkit docker-compose rails

smartcitizen-api's Introduction

SmartCitizen API

Maintainability Test Coverage DOI PRs Welcome

Installing Locally

To get the whole environment up locally (without Docker), you need to install and configure multiple technologies like:

  • Ruby on Rails
  • Postgres
  • Redis
  • Kairos
  • Cassandra
  • Nodejs

It is complex, that is why we recommend using Docker.

For developing a feature, you really only need Ruby on Rails and Postgres. We recommend using rbenv.

Docker quickstart

  1. Copy the environment file, and edit variables, domain name, etc

    cp env.example .env

  2. Copy the local development docker overrides: cp compose.override.local.yml compose.override.yml

  3. Start basic services (recommended)

    In a new terminal window do:

    docker compose up app db

    See the compose.yml file depends_on: section to see which containers depend on which.

    Available containers:

    • app - Rails app
    • db - Postgres
    • redis
    • web container which tries to get a certificate with Lets Encrypt.
    • mqtt EMQ + management interface on http://localhost:18083 admin:public
    • mqtt-task a rake task which subscribes to the mqtt service
    • sidekiq
    • kairos - Time series database on Cassandra
    • cassandra-1 - Stores the data

    Start ALL of them (not recommended) with:

    docker compose up

  4. (OPTIONAL) Start Cassandra cluster of 3 nodes

    If you want to start Kairos with 3 Cassandra cluster with 3 nodes:

    • Uncomment the other 2 cassandras in compose.yml file

    • Edit the file scripts/conf/kairosdb.properties and change the following line:

      kairosdb.datastore.cassandra.cql_host_list=cassandra-1

      docker compose up kairos cassandra-1 cassandra-2 cassandra-3

  5. Create the database (first time only)

    If you need to perfom many operations, it might be better to bash into the container:

    docker compose exec app bash

    and from here you can do

    bin/rails db:create

    bin/rails db:schema:load

    bin/rails db:seed

    Or you can run them all at once with: docker compose exec app bin/rails db:setup

  6. Removing everything

    Remove all containers + data volumes with:

    docker compose down -v

Running the tests on a local docker container:

(I'm not 100% clear why step (3) is needed, but for some reason the DATABASE_URL overrides the test database details in database.yml which causes problems)

  1. Make sure you're running the app and db containers as above: docker compose up app db

  2. In another terminal, get a shell within the app container: docker compose exec app bash

  3. Within that shell, unset the DATABASE_URL environment variable: unset DATABASE_URL

  4. Finally, run the tests (within that shell)! bundle exec bin/rake spec

Deploying

Using Docker

  1. SSH into the server
  2. git pull
  3. docker compose build
  4. docker compose up -d

Cassandra

Documentation and scripts to deploy and operate cassandra in production are available on scripts/cassandra.

Backup and restore

In the scripts/ folder there are backup and restore scripts for docker postgres.

Tools and scripts

We supply a nodejs helper post-readings.js tool to test sending massive amounts of data. Just like uploading a CSV file with a lot of readings.

To learn how to use it, do scripts/dev-tools/post-readings.js

You can also read more about the platform on docs/

Versioning

Currently using this tool to manually handle versioning: https://github.com/gregorym/bump

Use this command to update the VERSION file + create a git tag

bump patch --tag

Then push the git tag with:

git push --tags

Funding

This work has received funding from the European Union's Horizon 2020 research and innovation program under the grant agreement No. 689954

smartcitizen-api's People

Contributors

dependabot[bot] avatar johnrees avatar oscgonfer avatar paulormg avatar pral2a avatar rogerpales avatar rpales avatar timcowlishaw avatar tlmak0 avatar vicobarberan avatar viktorsmari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smartcitizen-api's Issues

[production][v0/uploads#uploaded] NoMethodError: undefined method `user' for nil:NilClass

See this exception on Errbit

NoMethodError: undefined method `user' for nil:NilClass

Summary

URL

https://new-api.smartcitizen.me/v0/avatars/uploaded"

Where

v0/uploads#uploaded

Occured

Nov 26 7:17pm

Similar

5

Params

{
  "action" => "uploaded",
  "controller" => "v0/uploads",
  "format" => "json",
  "key" => "devices/2394/csv_archive.csv"
}

Session

{}

Backtrace

28:  app/controllers/v0/uploads_controller.rb -> **uploaded**
4:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_controller/metal/implicit_render.rb -> **send_action**
198:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/abstract_controller/base.rb -> **process_action**
10:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_controller/metal/rendering.rb -> **process_action**
20:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/abstract_controller/callbacks.rb -> **block in process_action**
117:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **call**
117:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **call**
555:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **block (2 levels) in compile**
505:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **call**
505:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **call**
92:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **__run_callbacks__**
778:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **_run_process_action_callbacks**
81:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **run_callbacks**
19:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/abstract_controller/callbacks.rb -> **process_action**
29:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_controller/metal/rescue.rb -> **process_action**
32:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_controller/metal/instrumentation.rb -> **block in process_action**
164:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/notifications.rb -> **block in instrument**
20:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb -> **instrument**
164:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/notifications.rb -> **instrument**
30:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_controller/metal/instrumentation.rb -> **process_action**
18:  [GEM_ROOT]/gems/activerecord-4.2.5/lib/active_record/railties/controller_runtime.rb -> **process_action**
137:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/abstract_controller/base.rb -> **process**
30:  [GEM_ROOT]/gems/actionview-4.2.5/lib/action_view/rendering.rb -> **process**
196:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_controller/metal.rb -> **dispatch**
13:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_controller/metal/rack_delegation.rb -> **dispatch**
237:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_controller/metal.rb -> **block in action**
76:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb -> **call**
76:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb -> **dispatch**
45:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb -> **serve**
43:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/journey/router.rb -> **block in serve**
30:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/journey/router.rb -> **each**
30:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/journey/router.rb -> **serve**
817:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
30:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/rack/agent_hooks.rb -> **traced_call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
32:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/rack/browser_monitoring.rb -> **traced_call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
140:  [GEM_ROOT]/gems/rack-cache-1.5.1/lib/rack/cache/context.rb -> **forward**
147:  [GEM_ROOT]/gems/rack-cache-1.5.1/lib/rack/cache/context.rb -> **pass**
159:  [GEM_ROOT]/gems/rack-cache-1.5.1/lib/rack/cache/context.rb -> **invalidate**
74:  [GEM_ROOT]/gems/rack-cache-1.5.1/lib/rack/cache/context.rb -> **call!**
51:  [GEM_ROOT]/gems/rack-cache-1.5.1/lib/rack/cache/context.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
35:  [GEM_ROOT]/gems/rack-1.6.4/lib/rack/deflater.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
39:  [GEM_ROOT]/bundler/gems/versionist-248a667f3a7c/lib/versionist/middleware.rb -> **_call**
17:  [GEM_ROOT]/bundler/gems/versionist-248a667f3a7c/lib/versionist/middleware.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
24:  [GEM_ROOT]/gems/rack-1.6.4/lib/rack/etag.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
38:  [GEM_ROOT]/gems/rack-1.6.4/lib/rack/conditionalget.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
13:  [GEM_ROOT]/gems/rack-1.6.4/lib/rack/head.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
27:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/middleware/params_parser.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
36:  [GEM_ROOT]/gems/activerecord-4.2.5/lib/active_record/query_cache.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
653:  [GEM_ROOT]/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
29:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/middleware/callbacks.rb -> **block in call**
88:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **__run_callbacks__**
778:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **_run_call_callbacks**
81:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **run_callbacks**
27:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/middleware/callbacks.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
78:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/middleware/remote_ip.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
17:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/middleware/debug_exceptions.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
30:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/middleware/show_exceptions.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
15:  [GEM_ROOT]/gems/lograge-0.3.5/lib/lograge/rails_ext/rack/logger.rb -> **call_app**
20:  [GEM_ROOT]/gems/railties-4.2.5/lib/rails/rack/logger.rb -> **block in call**
68:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/tagged_logging.rb -> **block in tagged**
26:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/tagged_logging.rb -> **tagged**
68:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/tagged_logging.rb -> **tagged**
20:  [GEM_ROOT]/gems/railties-4.2.5/lib/rails/rack/logger.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
21:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/middleware/request_id.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
18:  [GEM_ROOT]/gems/rack-contrib-1.4.0/lib/rack/contrib/runtime.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
125:  [GEM_ROOT]/gems/rack-timeout-0.3.2/lib/rack/timeout/core.rb -> **block in call**
19:  [GEM_ROOT]/gems/rack-timeout-0.3.2/lib/rack/timeout/support/timeout.rb -> **call**
19:  [GEM_ROOT]/gems/rack-timeout-0.3.2/lib/rack/timeout/support/timeout.rb -> **timeout**
124:  [GEM_ROOT]/gems/rack-timeout-0.3.2/lib/rack/timeout/core.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
28:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/cache/strategy/local_cache_middleware.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
116:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/action_dispatch/middleware/static.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
11:  lib/header_check.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
80:  [GEM_ROOT]/gems/rack-cors-0.4.0/lib/rack/cors.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
518:  [GEM_ROOT]/gems/railties-4.2.5/lib/rails/engine.rb -> **call**
165:  [GEM_ROOT]/gems/railties-4.2.5/lib/rails/application.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
38:  [GEM_ROOT]/gems/rack-contrib-1.4.0/lib/rack/contrib/jsonp.rb -> **call**
78:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
562:  [GEM_ROOT]/gems/unicorn-5.0.1/lib/unicorn/http_server.rb -> **process_client**
658:  [GEM_ROOT]/gems/unicorn-5.0.1/lib/unicorn/http_server.rb -> **worker_loop**
508:  [GEM_ROOT]/gems/unicorn-5.0.1/lib/unicorn/http_server.rb -> **spawn_missing_workers**
132:  [GEM_ROOT]/gems/unicorn-5.0.1/lib/unicorn/http_server.rb -> **start**
126:  [GEM_ROOT]/gems/unicorn-5.0.1/bin/unicorn -> **<top (required)>**
23:  [GEM_ROOT]/bin/unicorn -> **load**
23:  [GEM_ROOT]/bin/unicorn -> **<main>**

Environment

Key Value
REMOTE_ADDR 127.0.0.1
REQUEST_METHOD POST
REQUEST_PATH /v0/avatars/uploaded
PATH_INFO /v0/avatars/uploaded
REQUEST_URI /v0/avatars/uploaded
SERVER_PROTOCOL HTTP/1.0
HTTP_VERSION HTTP/1.0
HTTP_X_FORWARDED_PROTO https
HTTP_X_FORWARDED_FOR 54.76.28.228, 162.158.39.230
HTTP_HOST new-api.smartcitizen.me
HTTP_CONNECTION close
CONTENT_LENGTH 38
HTTP_ACCEPT_ENCODING gzip
HTTP_CF_IPCOUNTRY IE
HTTP_CF_RAY 24b7ef2dce90298d-DUB
HTTP_CF_VISITOR {"scheme":"https"}
CONTENT_TYPE application/json
HTTP_CF_CONNECTING_IP 54.76.28.228
rack_url_scheme https
SERVER_NAME new-api.smartcitizen.me
SERVER_PORT 443
QUERY_STRING
unicorn_socket #<Kgio::Socket:0x0055a746f934e8>
rack_hijack #<Unicorn::HttpParser:0x0055a74238a218>
rack_multiprocess true
rack_multithread false
rack_run_once false
rack_version ["1", "2"]
rack_hijack? true
SCRIPT_NAME
SERVER_SOFTWARE Unicorn 5.0.1
rack_logger #<Logger:0x0055a7418a4bf0>
newrelic_transaction_started true
ORIGINAL_FULLPATH /v0/avatars/uploaded
ORIGINAL_SCRIPT_NAME
action_dispatch_parameter_filter ["password", "client_secret", "code", "token"]
action_dispatch_redirect_filter []
action_dispatch_show_exceptions true
action_dispatch_show_detailed_exceptions false
action_dispatch_cookies_serializer
action_dispatch_cookies_digest
ROUTES_47088475393680_SCRIPT_NAME
rack_cors #<Rack::Cors::Result:0x0055a746f91b98>
rack-timeout_info ["393d4e66c92cee18fdf95ba93f59c817", nil, "0.000240915", "15", "active"]
action_dispatch_request_id 57c4284a-0c4c-474c-bcdb-da8f7a2ddb7b
action_dispatch_remote_ip 162.158.39.230
action_dispatch_request_content_type application/json
RAW_POST_DATA {"key":"devices/2394/csv_archive.csv"}
action_dispatch_request_request_parameters {"key"=>"devices/2394/csv_archive.csv"}
rack-cache_cache_key Rack::Cache::Key
rack-cache_verbose true
rack-cache_metastore file:/var/cache/rack/meta
rack-cache_entitystore file:/var/cache/rack/body
rack-cache_default_ttl 0
rack-cache_ignore_headers ["Set-Cookie"]
rack-cache_private_headers ["Authorization", "Cookie"]
rack-cache_allow_reload false
rack-cache_allow_revalidate false
rack-cache_use_native_ttl false
action_dispatch_request_path_parameters {"format"=>"json", "controller"=>"v0/uploads", "action"=>"uploaded"}
rack_request_query_string
rack_request_query_hash
action_dispatch_request_query_parameters
action_dispatch_request_parameters {"key"=>"devices/2394/csv_archive.csv", "format"=>"json", "controller"=>"v0/uploads", "action"=>"uploaded"}
action_dispatch_request_formats ["application/json"]

Reset Password stacks on Google

Despite different link password-reset email stacks on Gmail. Make copy in subject and body unique enough so this does not happen

monit

add to all servers

CSV download

Support CSV data download for readingsas on the original platform

[production][unknown] JSON::ParserError: unexpected colon at line 1, column 62 [parse.c:586]

See this exception on Errbit

JSON::ParserError: unexpected colon at line 1, column 62 [parse.c:586]

Summary

Where

unknown

Occured

Nov 11 7:59pm

Similar

11

Params

{}

Session

{}

Backtrace

38:  lib/mqtt_messages_handler.rb -> **parse**
38:  lib/mqtt_messages_handler.rb -> **data**
16:  lib/mqtt_messages_handler.rb -> **handle_readings**
4:  lib/mqtt_messages_handler.rb -> **handle**
10:  config/initializers/mqtt.rb -> **block (4 levels) in &lt;top (required)&gt;**
103:  [GEM_ROOT]/gems/em-mqtt-0.0.5/lib/em/mqtt/client_connection.rb -> **call**
103:  [GEM_ROOT]/gems/em-mqtt-0.0.5/lib/em/mqtt/client_connection.rb -> **receive_msg**
167:  [GEM_ROOT]/gems/em-mqtt-0.0.5/lib/em/mqtt/client_connection.rb -> **process_packet**
37:  [GEM_ROOT]/gems/em-mqtt-0.0.5/lib/em/mqtt/connection.rb -> **receive_data**
194:  [GEM_ROOT]/gems/eventmachine-1.2.0.1/lib/eventmachine.rb -> **run_machine**
194:  [GEM_ROOT]/gems/eventmachine-1.2.0.1/lib/eventmachine.rb -> **run**
4:  config/initializers/mqtt.rb -> **block in &lt;top (required)&gt;**

Inserts validation policies

We should create a device data policy for inserts. Currently supporting the legacy API and later moving in to all the insert possibilities:

Insert Polices

(note order is important if rule fails it is catch on the rule, breaks and nothing is inserted, just logged)

# /add Payload validation:

โ€‹_Notes: From now on we will require all the devices to publish with X-SmartCitizenVersion. This means devices with firmware 0.8.4 or older will need to upgrade but most already are.__

X-SmartCitizenMacADDR - Key is not null and mac property format is valid
X-SmartCitizenVersion - Key is not null and version property format is valid
X-SmartCitizenData - Key is not null and json property is valid

โ€‹_Catch:_โ€‹ Request failing to pass are logged with tag: WRONG_PAYLOAD. Logging should include: Original payload, Timestamp and Source IP. A daily report on those device will be really good to manually monitor unhealthy devices.

# /add Device validation:

X-SmartCitizenMacADDR - Is validated against the devices list. Device id is find.

โ€‹_Catch:_โ€‹ Request failing to pass are logged tag: UNREGISTERED_DEVICE. Logging should include: Original payload, Timestamp and Source IP. A daily report on those device will be really good to manually monitor unhealthy devices.

# /add Timestamp validation:

X-SmartCitizenData - Timestamp properties are validated against data formatting and maybe time ranges (max 1 year)

โ€‹_Catch:_โ€‹ Request failing to pass are logged tag: WRONG_TIMESTAMP. Logging should include: Original payload, Timestamp and Source IP. A daily report on those device will be really good to manually monitor unhealthy devices. Because device ID is known we can notify users.

# /add Data validation:

X-SmartCitizenData - Data keys are validated against sensor list, properties are validated against data types(isNaN) and sensor ranges.

โ€‹_Catch:_โ€‹ Request failing to pass are logged tag: WRONG_DATA. Logging should include: Original payload, Timestamp and Source IP. A daily report on those device will be really good to manually monitor unhealthy devices. Because device ID is known we can notify users. (edited)

[production][unknown] RuntimeError: device not found

See this exception on Errbit

RuntimeError: device not found

Summary

Where

unknown

Occured

Nov 10 7:54pm

Similar

133

Params

{}

Session

{}

Backtrace

14:  lib/mqtt_messages_handler.rb -> **handle_readings**
4:  lib/mqtt_messages_handler.rb -> **handle**
10:  config/initializers/mqtt.rb -> **block (4 levels) in &lt;top (required)&gt;**
103:  [GEM_ROOT]/gems/em-mqtt-0.0.5/lib/em/mqtt/client_connection.rb -> **call**
103:  [GEM_ROOT]/gems/em-mqtt-0.0.5/lib/em/mqtt/client_connection.rb -> **receive_msg**
167:  [GEM_ROOT]/gems/em-mqtt-0.0.5/lib/em/mqtt/client_connection.rb -> **process_packet**
37:  [GEM_ROOT]/gems/em-mqtt-0.0.5/lib/em/mqtt/connection.rb -> **receive_data**
194:  [GEM_ROOT]/gems/eventmachine-1.2.0.1/lib/eventmachine.rb -> **run_machine**
194:  [GEM_ROOT]/gems/eventmachine-1.2.0.1/lib/eventmachine.rb -> **run**
4:  config/initializers/mqtt.rb -> **block in &lt;top (required)&gt;**

Check logs

  • Check and reduce log verbosity
  • Check logrotate works fine

From now on logrotate for smartcitizen_production runs on crontab -u deployer -e as 0 5 * * * logrotate --state /home/deployer/apps/smartcitizen_production/shared/log/state /home/deployer/apps/smartcitizen_production/shared/config/log_rotation

Defining the final API for the '/add' end-point

Defining and implementing the final /add end-point aside from the legacy one. Maybe should be POST /readings.

This will complement the future MQTT end-point, too.

Completely open to discussion.

[production][unknown] NoMethodError: undefined method `find_sensor_id_by_key' for #<Device:0x005593ce6a4098>

See this exception on Errbit

NoMethodError: undefined method `find_sensor_id_by_key' for #<Device:0x005593cee89ce0>

Summary

Where

unknown

Occured

Nov 23 1:30pm

Similar

53475

Params

{}

Session

{}

Backtrace

433:  [GEM_ROOT]/gems/activemodel-4.2.7.1/lib/active_model/attribute_methods.rb -> **method_missing**
80:  [GEM_ROOT]/gems/pg_search-1.0.6/lib/pg_search.rb -> **method_missing**
49:  app/models/concerns/data_parser/storer.rb -> **rescue in sensor_reading**
44:  app/models/concerns/data_parser/storer.rb -> **sensor_reading**
18:  app/models/concerns/data_parser/storer.rb -> **block in parse_reading**
17:  app/models/concerns/data_parser/storer.rb -> **each**
17:  app/models/concerns/data_parser/storer.rb -> **parse_reading**
9:  app/models/storer.rb -> **initialize**
21:  lib/mqtt_messages_handler.rb -> **new**
21:  lib/mqtt_messages_handler.rb -> **block in handle_readings**
20:  lib/mqtt_messages_handler.rb -> **each**
20:  lib/mqtt_messages_handler.rb -> **handle_readings**
8:  lib/mqtt_messages_handler.rb -> **handle_topic**
21:  lib/tasks/mqtt_subscriber.rake -> **block (4 levels) in &lt;top (required)&gt;**
399:  [GEM_ROOT]/gems/mqtt-0.4.0/lib/mqtt/client.rb -> **block in get**
429:  [GEM_ROOT]/gems/mqtt-0.4.0/lib/mqtt/client.rb -> **block in get_packet**
427:  [GEM_ROOT]/gems/mqtt-0.4.0/lib/mqtt/client.rb -> **loop**
427:  [GEM_ROOT]/gems/mqtt-0.4.0/lib/mqtt/client.rb -> **get_packet**
398:  [GEM_ROOT]/gems/mqtt-0.4.0/lib/mqtt/client.rb -> **get**
19:  lib/tasks/mqtt_subscriber.rake -> **block (3 levels) in &lt;top (required)&gt;**
304:  [GEM_ROOT]/gems/mqtt-0.4.0/lib/mqtt/client.rb -> **connect**
93:  [GEM_ROOT]/gems/mqtt-0.4.0/lib/mqtt/client.rb -> **connect**
10:  lib/tasks/mqtt_subscriber.rake -> **block (2 levels) in &lt;top (required)&gt;**
248:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/task.rb -> **call**
248:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/task.rb -> **block in execute**
243:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/task.rb -> **each**
243:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/task.rb -> **execute**
187:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/task.rb -> **block in invoke_with_call_chain**
211:  /home/deployer/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb -> **mon_synchronize**
180:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/task.rb -> **invoke_with_call_chain**
173:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/task.rb -> **invoke**
152:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **invoke_task**
108:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **block (2 levels) in top_level**
108:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **each**
108:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **block in top_level**
117:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **run_with_threads**
102:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **top_level**
80:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **block in run**
178:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **standard_exception_handling**
77:  [GEM_ROOT]/gems/rake-11.3.0/lib/rake/application.rb -> **run**
27:  [GEM_ROOT]/gems/rake-11.3.0/exe/rake -> **&lt;top (required)&gt;**
23:  [GEM_ROOT]/bin/rake -> **load**
23:  [GEM_ROOT]/bin/rake -> **&lt;main&gt;**

Fix CSV download

When a user request a CSV containing all his kit data we process the request, push the file to S3 and email him with the download link

http://developer.smartcitizen.me/#csv-archive-of-readings

This module currently is hardcoded for kits_id 2 and 3 and not capable of supporting data download from new kits.

We simply need to:

  • Change the way we obtain the key by using the kits.sensor_map jsonb

https://github.com/fablabbcn/smartcitizen/blob/6bddb28c8ff79d8b3f4d944b8088ac854b1659a3/app/mailers/user_mailer.rb#L20

  • Generate the csv first 3 rows by mapping the sensor names and descriptions as:

measurement.name in sensor.units (sensor.name)

Timestamp NO2 in kOhm (MiCS-4514) ...

https://github.com/fablabbcn/smartcitizen/blob/6bddb28c8ff79d8b3f4d944b8088ac854b1659a3/app/mailers/user_mailer.rb#L36

  • We will name the file {device.id_datetime}.csv

https://github.com/fablabbcn/smartcitizen/blob/6bddb28c8ff79d8b3f4d944b8088ac854b1659a3/app/mailers/user_mailer.rb#L55

  • Previous tasks are top priority in order to support users Then after we need to refactor the data csv export since it is too memory intensive. I suggest we through row per row in to disk or we directly stream to S3 since Fog already supports this.

https://github.com/fablabbcn/smartcitizen/blob/6bddb28c8ff79d8b3f4d944b8088ac854b1659a3/app/mailers/user_mailer.rb#L36-L37

[production][unknown] ActionView::MissingTemplate: Missing template user_mailer/welcome with "mailer". Searched in: *...

See this exception on Errbit

ActionView::MissingTemplate: Missing template user_mailer/welcome with "mailer". Searched in:

  • "user_mailer"

    Summary

    Where

    unknown

Occured

Nov 26 2:16pm

Similar

2

Params

{
  &quot;args&quot; =&gt; &quot;[\&quot;---\\n- !ruby/class &#39;UserMailer&#39;\\n- :welcome\\n- - 5002\\n\&quot;]&quot;,
  &quot;class&quot; =&gt; &quot;Sidekiq::Extensions::DelayedMailer&quot;,
  &quot;created_at&quot; =&gt; &quot;1448547365.16112&quot;,
  &quot;enqueued_at&quot; =&gt; &quot;1448547365.16123&quot;,
  &quot;error_class&quot; =&gt; &quot;ActionView::MissingTemplate&quot;,
  &quot;error_message&quot; =&gt; &quot;Missing template user_mailer/welcome with \&quot;mailer\&quot;. Searched in:\n  * \&quot;user_mailer\&quot;\n&quot;,
  &quot;failed_at&quot; =&gt; &quot;1448547365.179564&quot;,
  &quot;jid&quot; =&gt; &quot;1261525078a5892877bfcf19&quot;,
  &quot;queue&quot; =&gt; &quot;default&quot;,
  &quot;retry&quot; =&gt; &quot;true&quot;,
  &quot;retry_count&quot; =&gt; &quot;0&quot;
}

Session

{}

Backtrace

916:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/base.rb -> **each_template**
900:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/base.rb -> **collect_responses**
829:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/base.rb -> **mail**
8:  app/mailers/user_mailer.rb -> **welcome**
198:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/abstract_controller/base.rb -> **process_action**
20:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/abstract_controller/callbacks.rb -> **block in process_action**
88:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **__run_callbacks__**
778:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **_run_process_action_callbacks**
81:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/callbacks.rb -> **run_callbacks**
19:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/abstract_controller/callbacks.rb -> **process_action**
137:  [GEM_ROOT]/gems/actionpack-4.2.5/lib/abstract_controller/base.rb -> **process**
30:  [GEM_ROOT]/gems/actionview-4.2.5/lib/action_view/rendering.rb -> **process**
596:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/base.rb -> **block in process**
164:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/notifications.rb -> **block in instrument**
20:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb -> **instrument**
164:  [GEM_ROOT]/gems/activesupport-4.2.5/lib/active_support/notifications.rb -> **instrument**
593:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/base.rb -> **process**
584:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/base.rb -> **initialize**
25:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/message_delivery.rb -> **new**
25:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/message_delivery.rb -> **__getobj__**
34:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/message_delivery.rb -> **message**
85:  [GEM_ROOT]/gems/actionmailer-4.2.5/lib/action_mailer/message_delivery.rb -> **deliver_now**
32:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/extensions/action_mailer.rb -> **deliver**
21:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/extensions/action_mailer.rb -> **perform**
75:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb -> **execute_job**
52:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb -> **block (2 levels) in process**
127:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb -> **block in invoke**
33:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/sidekiq.rb -> **block in call**
362:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/controller_instrumentation.rb -> **perform_action_with_newrelic_trace**
29:  [GEM_ROOT]/gems/newrelic_rpm-3.14.0.305/lib/new_relic/agent/instrumentation/sidekiq.rb -> **call**
129:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb -> **block in invoke**
6:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/server/active_record.rb -> **call**
129:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb -> **block in invoke**
74:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/server/retry_jobs.rb -> **call**
129:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb -> **block in invoke**
15:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/server/logging.rb -> **block in call**
30:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/logging.rb -> **with_context**
11:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/server/logging.rb -> **call**
129:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb -> **block in invoke**
132:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb -> **call**
132:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb -> **invoke**
51:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb -> **block in process**
98:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb -> **stats**
50:  [GEM_ROOT]/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb -> **process**
26:  [GEM_ROOT]/gems/celluloid-0.16.0/lib/celluloid/calls.rb -> **public_send**
26:  [GEM_ROOT]/gems/celluloid-0.16.0/lib/celluloid/calls.rb -> **dispatch**
122:  [GEM_ROOT]/gems/celluloid-0.16.0/lib/celluloid/calls.rb -> **dispatch**
60:  [GEM_ROOT]/gems/celluloid-0.16.0/lib/celluloid/cell.rb -> **block in invoke**
71:  [GEM_ROOT]/gems/celluloid-0.16.0/lib/celluloid/cell.rb -> **block in task**
357:  [GEM_ROOT]/gems/celluloid-0.16.0/lib/celluloid/actor.rb -> **block in task**
57:  [GEM_ROOT]/gems/celluloid-0.16.0/lib/celluloid/tasks.rb -> **block in initialize**
15:  [GEM_ROOT]/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb -> **block in create**

move smartcitizen image processor off heroku

(Editing John's comment so the info will stay at the top of the issue)

We can use Rails 5 built in Active Storage.
See: https://edgeguides.rubyonrails.org/active_storage_overview.html

We are currently using: https://github.com/jimmynicol/image-resizer
Which stores Avatar URLs in User.avatar_url

Thoughts

  1. If we use Active Storage, the URL will be saved in the same User.avatar_url or a new one?
  2. We need to be able to call it using the same method
    • User.avatar_url needs to be able to work on both the old and the new approach

Notes

  • We need to add has_one_attached :avatar

Support devices Tags

Support devices tags together with system_tags, they can be maybe called user_tags or simply tags.

  • Tags creation is curated by the platform admin. (A tags end point is need it for creating, updating and reading, listing available tags is accessible to all users)
  • Users can assign Tags to devices but not create them
  • Tags can be searched
  • Tags will have an id, name, creation date, modified date and description. In some things the data structure and functions is not far from devices

Exposure as system tag

Exposure is managed at location for user editing purposes but it is also returned on system_tags for flexibility.

"system_tags": [ "offline", "outdoor" ]

"location": { "city": null, "country": null, "country_code": null, "elevation": null, "exposure": null, "geohash": null, "ip": null, "latitude": null, "longitude": null }

SD data import

File upload end-point for supporting CSV files recorded by the SCK on the SD card. Implementation should be as on the original platform but legacy support can be discussed.

Rename Kit to avoid confusion

Kit must be renamed before launch as it is used as the noun to refer to a device in the frontend and will cause a lot of confusion for people using the API

  • Kit needs to be changed to a more generic, abstract noun. One that indicates a predefined collection of sensors
  • device.kit_id will need to be updated to reflect this change

ideas are...

Template
Blueprint
Board < I am not sure about this as it adds a 'physical constraint', maybe some sensors will not be attached to boards in the future

suggestions are very welcome

/cc @pral2a

Issues with the global search API

See this exception on Errbit

NoMethodError: undefined method `name' for nil:NilClass

Summary

URL

http://api.smartcitizen.me/v0/search?q=vico"

Where

v0/static#search

Occured

Dec 02 5:10pm

Similar

10

Params

{
  &quot;action&quot; =&gt; &quot;search&quot;,
  &quot;controller&quot; =&gt; &quot;v0/static&quot;,
  &quot;format&quot; =&gt; &quot;json&quot;,
  &quot;q&quot; =&gt; &quot;vico&quot;
}

Session

{}

Backtrace

107:  app/controllers/v0/static_controller.rb -> **block in search**
46:  [GEM_ROOT]/gems/activerecord-4.2.7.1/lib/active_record/relation/delegation.rb -> **each**
46:  [GEM_ROOT]/gems/activerecord-4.2.7.1/lib/active_record/relation/delegation.rb -> **each**
102:  app/controllers/v0/static_controller.rb -> **search**
4:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_controller/metal/implicit_render.rb -> **send_action**
198:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/abstract_controller/base.rb -> **process_action**
10:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_controller/metal/rendering.rb -> **process_action**
20:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/abstract_controller/callbacks.rb -> **block in process_action**
117:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **call**
117:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **call**
555:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **block (2 levels) in compile**
505:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **call**
505:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **call**
92:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **__run_callbacks__**
778:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **_run_process_action_callbacks**
81:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **run_callbacks**
19:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/abstract_controller/callbacks.rb -> **process_action**
29:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_controller/metal/rescue.rb -> **process_action**
32:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_controller/metal/instrumentation.rb -> **block in process_action**
164:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb -> **block in instrument**
20:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb -> **instrument**
164:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb -> **instrument**
30:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_controller/metal/instrumentation.rb -> **process_action**
18:  [GEM_ROOT]/gems/activerecord-4.2.7.1/lib/active_record/railties/controller_runtime.rb -> **process_action**
137:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/abstract_controller/base.rb -> **process**
30:  [GEM_ROOT]/gems/actionview-4.2.7.1/lib/action_view/rendering.rb -> **process**
196:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_controller/metal.rb -> **dispatch**
13:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_controller/metal/rack_delegation.rb -> **dispatch**
237:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_controller/metal.rb -> **block in action**
74:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb -> **call**
74:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb -> **dispatch**
43:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb -> **serve**
43:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb -> **block in serve**
30:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb -> **each**
30:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb -> **serve**
817:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
30:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/rack/agent_hooks.rb -> **traced_call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
32:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/rack/browser_monitoring.rb -> **traced_call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
140:  [GEM_ROOT]/gems/rack-cache-1.6.1/lib/rack/cache/context.rb -> **forward**
249:  [GEM_ROOT]/gems/rack-cache-1.6.1/lib/rack/cache/context.rb -> **fetch**
189:  [GEM_ROOT]/gems/rack-cache-1.6.1/lib/rack/cache/context.rb -> **lookup**
66:  [GEM_ROOT]/gems/rack-cache-1.6.1/lib/rack/cache/context.rb -> **call!**
51:  [GEM_ROOT]/gems/rack-cache-1.6.1/lib/rack/cache/context.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
39:  [GEM_ROOT]/bundler/gems/versionist-f6fe218c295c/lib/versionist/middleware.rb -> **_call**
17:  [GEM_ROOT]/bundler/gems/versionist-f6fe218c295c/lib/versionist/middleware.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
24:  [GEM_ROOT]/gems/rack-1.6.4/lib/rack/etag.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
25:  [GEM_ROOT]/gems/rack-1.6.4/lib/rack/conditionalget.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
13:  [GEM_ROOT]/gems/rack-1.6.4/lib/rack/head.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
27:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/params_parser.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
36:  [GEM_ROOT]/gems/activerecord-4.2.7.1/lib/active_record/query_cache.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
653:  [GEM_ROOT]/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
29:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb -> **block in call**
88:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **__run_callbacks__**
778:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **_run_call_callbacks**
81:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb -> **run_callbacks**
27:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
78:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/remote_ip.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
17:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/debug_exceptions.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
30:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/show_exceptions.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
15:  [GEM_ROOT]/gems/lograge-0.4.1/lib/lograge/rails_ext/rack/logger.rb -> **call_app**
20:  [GEM_ROOT]/gems/railties-4.2.7.1/lib/rails/rack/logger.rb -> **block in call**
68:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/tagged_logging.rb -> **block in tagged**
26:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/tagged_logging.rb -> **tagged**
68:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/tagged_logging.rb -> **tagged**
20:  [GEM_ROOT]/gems/railties-4.2.7.1/lib/rails/rack/logger.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
21:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/request_id.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
18:  [GEM_ROOT]/gems/rack-contrib-1.4.0/lib/rack/contrib/runtime.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
122:  [GEM_ROOT]/gems/rack-timeout-0.4.2/lib/rack/timeout/core.rb -> **block in call**
19:  [GEM_ROOT]/gems/rack-timeout-0.4.2/lib/rack/timeout/support/timeout.rb -> **call**
19:  [GEM_ROOT]/gems/rack-timeout-0.4.2/lib/rack/timeout/support/timeout.rb -> **timeout**
121:  [GEM_ROOT]/gems/rack-timeout-0.4.2/lib/rack/timeout/core.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
28:  [GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/cache/strategy/local_cache_middleware.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
120:  [GEM_ROOT]/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/static.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
8:  lib/delete_response_headers.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
11:  lib/header_check.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
80:  [GEM_ROOT]/gems/rack-cors-0.4.0/lib/rack/cors.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
518:  [GEM_ROOT]/gems/railties-4.2.7.1/lib/rails/engine.rb -> **call**
165:  [GEM_ROOT]/gems/railties-4.2.7.1/lib/rails/application.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
38:  [GEM_ROOT]/gems/rack-contrib-1.4.0/lib/rack/contrib/jsonp.rb -> **call**
96:  [GEM_ROOT]/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/middleware_tracing.rb -> **call**
562:  [GEM_ROOT]/gems/unicorn-5.1.0/lib/unicorn/http_server.rb -> **process_client**
658:  [GEM_ROOT]/gems/unicorn-5.1.0/lib/unicorn/http_server.rb -> **worker_loop**
508:  [GEM_ROOT]/gems/unicorn-5.1.0/lib/unicorn/http_server.rb -> **spawn_missing_workers**
519:  [GEM_ROOT]/gems/unicorn-5.1.0/lib/unicorn/http_server.rb -> **maintain_worker_count**
283:  [GEM_ROOT]/gems/unicorn-5.1.0/lib/unicorn/http_server.rb -> **join**
126:  [GEM_ROOT]/gems/unicorn-5.1.0/bin/unicorn -> **&lt;top (required)&gt;**
23:  [GEM_ROOT]/bin/unicorn -> **load**
23:  [GEM_ROOT]/bin/unicorn -> **&lt;main&gt;**

Environment

Key Value
REMOTE_ADDR 127.0.0.1
REQUEST_METHOD GET
REQUEST_PATH /v0/search
PATH_INFO /v0/search
QUERY_STRING q=vico
REQUEST_URI /v0/search?q=vico
SERVER_PROTOCOL HTTP/1.0
HTTP_VERSION HTTP/1.0
HTTP_X_FORWARDED_PROTO http
HTTP_X_FORWARDED_FOR 91.126.132.3, 172.68.95.32
HTTP_HOST api.smartcitizen.me
HTTP_CONNECTION close
HTTP_ACCEPT_ENCODING gzip
HTTP_CF_IPCOUNTRY ES
HTTP_CF_RAY 30b00c12fa7c6193-BCN
HTTP_CF_VISITOR {"scheme":"https"}
HTTP_ACCEPT application/json, text/plain, /
HTTP_ORIGIN https://smartcitizen.me
HTTP_USER_AGENT Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36
HTTP_REFERER https://smartcitizen.me/kits/
HTTP_ACCEPT_LANGUAGE ca,es;q=0.8,en-US;q=0.6,en;q=0.4,fr;q=0.2
HTTP_CF_CONNECTING_IP 91.126.132.3
rack_url_scheme http
SERVER_NAME api.smartcitizen.me
SERVER_PORT 80
unicorn_socket #<Kgio::Socket:0x0055f818cbbd10>
rack_hijack #<Unicorn::HttpParser:0x0055f80be9c3d0>
rack_multiprocess true
rack_multithread false
rack_run_once false
rack_version ["1", "2"]
rack_hijack? true
SCRIPT_NAME
SERVER_SOFTWARE Unicorn 5.1.0
rack_logger #<Logger:0x0055f80c08a278>
newrelic_transaction_started true
ORIGINAL_FULLPATH /v0/search?q=vico
ORIGINAL_SCRIPT_NAME
action_dispatch_parameter_filter ["password", "(?-mix:^((?-mix:client_secret
action_dispatch_redirect_filter []
action_dispatch_show_exceptions true
action_dispatch_show_detailed_exceptions false
action_dispatch_cookies_serializer
action_dispatch_cookies_digest
ROUTES_47261960476460_SCRIPT_NAME
rack_cors #<Rack::Cors::Result:0x0055f818cbad48>
rack-timeout_info ["bd5aa4a5ce4aec19d26b54e2b30de964", nil, "0.0002581870649009943", "15", "active"]
action_dispatch_request_id 513b30f4-a482-4d64-ab16-66eac59a8696
action_dispatch_remote_ip 172.68.95.32
rack-cache_cache_key Rack::Cache::Key
rack-cache_verbose true
rack-cache_metastore file:/var/cache/rack/meta
rack-cache_entitystore file:/var/cache/rack/body
rack-cache_default_ttl 0
rack-cache_ignore_headers ["Set-Cookie"]
rack-cache_private_headers ["Authorization", "Cookie"]
rack-cache_allow_reload false
rack-cache_allow_revalidate false
rack-cache_use_native_ttl false
action_dispatch_request_path_parameters {"format"=>"json", "controller"=>"v0/static", "action"=>"search"}
action_dispatch_request_content_type
action_dispatch_request_request_parameters
rack_request_query_string q=vico
rack_request_query_hash {"q"=>"vico"}
action_dispatch_request_query_parameters {"q"=>"vico"}
action_dispatch_request_parameters {"q"=>"vico", "format"=>"json", "controller"=>"v0/static", "action"=>"search"}
action_dispatch_request_formats ["application/json"]

Disqus better integration

Research and discuss a better Disqus integration.

  • Supporting users single logging.
  • Implementing a hook system to alert users when they write on their own device.

Ref:
https://help.disqus.com/customer/portal/articles/466187-how-does-disqus-work-
https://help.disqus.com/customer/portal/articles/236206-integrating-single-sign-on
https://github.com/disqus/DISQUS-API-Recipes

This should be evaluated and a decision must be take in order to implement this temporary or directly move to our own comments system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.