This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mongoid.default_session["survey_responses"].find.each_with_index do |response, index| | |
summary = {} | |
other_text_summary = {} | |
(response["answers"] || []).each do |answer| | |
if answer["_type"] == "Survey::Answers::Multiselect" | |
choices = (answer["selections"] || []).map { |s| s && s["answer_choice_id"] && s["answer_choice_id"].to_s } | |
summary[answer["question_id"].to_s] = choices if choices.present? | |
other = (answer["selections"] || []).detect { |s| s && s["text"].present? } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (0.3254ms) | |
MOPED: Could not connect to any node in replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:27017">]>, refreshing list. | |
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (0.9255ms) | |
MOPED: 127.0.0.1:27017 COMMAND database=apptentive_production command={:count=>"survey_responses", :query=>{"deleted_at"=>nil, "survey_id"=>"572bdf52fd7381d6ee000004", "summary.572bdf52fd7381d6ee000008"=>{:$exists=>true}}} (555.3071ms) | |
=> 4838 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails.logger.debug "[reviews report] building review data for app (#{app.id})" | |
token = make_jwt_token(user, app) | |
start_date = if user.last_review_email.present? && !env["force_emails"] | |
(user.last_review_email - 1.day).to_date | |
else | |
30.days.ago.to_date | |
end | |
start_date = [start_date, app.organization.active_entitlement.days_of_reviews_history.days.ago.to_date].max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- for id, app in @email[:app_reviews] | |
- reviews_link = "#{root_url}apps/#{id}/reviews?start_date=#{app[:start_date].to_s}&end_date=#{@email[:end_date].to_s}&#{ga_suffix}" | |
- store_name = app[:store].downcase == 'itunes' ? 'App Store' : 'Google Play' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Response | |
attr_accessor :data | |
delegate :[], :map, :select, :each, :first, :inject, to: :data | |
def initialize(data = nil) | |
self.data = data | |
end | |
def value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PullUpErrors | |
extend ActiveSupport::Concern | |
# Used to pull up errors that are on an associated collection or object | |
included do | |
after_validation :pull_up_errors | |
def pull_up_errors(*attrs) | |
@pull_up_attrs = Array(attrs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
require 'faraday_middleware' | |
require 'active_support/all' | |
def period(app_id, start_date, end_date) | |
date = start_date | |
results = [] | |
while date <= end_date do | |
results << { date: date.strftime("%F"), dau: day(app_id, date) } | |
date = (date + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In express middleware when a request comes in we start a transaction | |
// and store it in continuation local store (think thread local store) | |
// Create a new user in the DB and return the newly created User instance | |
let user = await User.create({name: "Sally Smith", email: "[email protected]"}); | |
user.setAddressStreet1("123 Main St."); // With no Typescript | |
user.addressStreet1 = "123 Main St."; // If we introduce Typescript this would be okay too |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
self.resource = resource_class.send_confirmation_instructions(resource_params) | |
yield resource if block_given? | |
render_resource(resource, blueprint: :admin) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
def google_oauth2 | |
auth = request.env['omniauth.auth'] | |
manager = Manager.where(provider: auth['provider'], uid: auth['uid']) | |
.first_or_initialize(email: auth['info']['email']) | |
manager.first_name = auth['info']['first_name'] | |
manager.last_name = auth['info']['last_name'] | |
manager.save! |