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
/** | |
* Calls provided HTTP requests batch and retries in case of errors | |
* | |
* @param {object} fetchService - service for performing HTTP requests. Defaults to UrlFetchApp provided by Google. | |
* @param {Array<object>} requests - Array of request param objects | |
* (https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchurl-params) | |
* | |
* @return {object} RetriableRequestsBatch. | |
*/ | |
function RetriableRequestsBatch(fetchService, requests) { |
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 Loader | |
def load | |
Enumerator.new { |main_enum| stream(main_enum) } | |
end | |
private | |
def stream(main_enum) | |
reader = nil | |
file_uri.open do |file| |
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
# Javascript Node CircleCI 2.0 configuration file | |
# | |
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | |
# | |
version: 2 | |
jobs: | |
build: | |
docker: | |
- image: circleci/node:7.10 |
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
var oauth = {}; | |
/** @const */ | |
oauth.OAUTH_CLIENT_ID = 'OAUTH_CLIENT_ID'; | |
/** @const */ | |
oauth.OAUTH_CLIENT_SECRET = 'OAUTH_CLIENT_SECRET'; | |
/** | |
* This builds an OAuth2 service for connecting to Spotify |
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
/** | |
* Constructor for DataCache. | |
* More info on caching: https://developers.google.com/apps-script/reference/cache/cache | |
* | |
* @param {object} cacheService - GDS caching service | |
* @param {Date} startDate - beggining of GDS request interval | |
* @param {Date} endDate - end of GDS request interval | |
* | |
* @return {object} DataCache. | |
*/ |
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
# frozen_string_literal: true | |
require "net/ftp" | |
class Loader | |
def load | |
Enumerator.new { |main_enum| stream(main_enum) } | |
end | |
private |
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 BaseApiController | |
def render_json_api(options) | |
render( | |
options.merge(included).merge(fields: fields).merge(adapter: :json_api) | |
) | |
end | |
# Allows limiting fields in given resource type's payloads. | |
# `fields` param is sent as a hash in which: | |
# - keys are singular or plural resource names (e.g. `accounts` or `account`) |
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 BaseSerializer < ActiveModel::Serializer | |
include AmsLazyRelationships::Core | |
end | |
class PostSerializer < BaseSerializer | |
attributes :id, :title | |
lazy_belongs_to :user | |
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 PostSerializer < ActiveModel::Serializer | |
attributes :id, :title | |
belongs_to :user | |
def self.lazy_user(post) | |
BatchLoader.for(post.user_id).batch do |user_ids| | |
User.where(id: user_ids) | |
end | |
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
users = posts.map { |post| post.user_lazy } | |
users.each { |user| puts "#{user.name}" } # SELECT * FROM users WHERE id IN (1, 2, 3) | |
users.each { |user| puts "#{user.address}" } # Pobierze użytkowników z cache'u |
NewerOlder