Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 3008-fix-select-all…
Browse files Browse the repository at this point in the history
…-switch
  • Loading branch information
alonsogarciapablo committed Apr 6, 2015
2 parents 546a888 + d347107 commit f09e2c0
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 29 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gem 'nokogiri', '~> 1.6.6.2'
gem 'statsd-client', '0.0.7', require: 'statsd'
gem 'aws-sdk', '1.8.5'
gem 'ruby-prof', '0.15.1'
gem 'request_store', '1.1.0'

# It's used in the dataimport and arcgis.
# It's a replacement for the ruby uri that it's supposed to perform better parsing of a URI
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ GEM
redis-namespace (1.5.1)
redis (~> 3.0, >= 3.0.4)
ref (1.0.5)
request_store (1.1.0)
resque (1.25.2)
mono_logger (~> 1.0)
multi_json (~> 1.0)
Expand Down Expand Up @@ -354,6 +355,7 @@ DEPENDENCIES
rb-readline
redcarpet (= 3.2.2)
redis (= 3.2.1)
request_store (= 1.1.0)
resque (= 1.25.2)
resque-metrics (= 0.1.1)
retriable (= 1.4.1)
Expand Down
8 changes: 4 additions & 4 deletions app/assets/stylesheets/new_common/datasets-list.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $bannedColor: #E1A7A5;
@include display-flex();
width: 100%;
padding: $sMargin-group 0;
border-bottom: 1px solid $cStructure-mainLine;
border-bottom: 1px solid $cStructure-softLine;
}
.DatasetsList-item--selectable:hover,
.DatasetsList-item--selectable.is--selected {
Expand Down Expand Up @@ -98,7 +98,7 @@ $bannedColor: #E1A7A5;
.DatasetsList-itemCategory.is--lineDataset { @include geometry-type-icon(-40px, -40px) }
.DatasetsList-itemCategory.is--polygonDataset { @include geometry-type-icon(-80px, -40px) }
.DatasetsList-itemCategory.is--pointDataset { @include geometry-type-icon(0, -40px) }
.DatasetsList-itemCategory.is--rasterDataset { @include geometry-type-icon(-120px, -40px) }
.DatasetsList-itemCategory.is--rasterDataset { @include geometry-type-icon(-120px, -40px) }
}

.DatasetsList-itemStatus {
Expand Down Expand Up @@ -173,7 +173,7 @@ $bannedColor: #E1A7A5;
.DatasetsList-itemMeta > *:nth-child(4) { @include flex-order(4) }
.DatasetsList-itemMeta > *:nth-child(5) { @include flex-order(5) }

.DatasetsList-itemTags {
.DatasetsList-itemTags {
margin-top: 4px;
text-align: right;
}
Expand All @@ -192,7 +192,7 @@ $bannedColor: #E1A7A5;
.DatasetsList-itemCategory.is--polygonDataset { @include geometry-type-icon(-80px, -80px) }
.DatasetsList-itemCategory.is--pointDataset { @include geometry-type-icon(0, -80px) }
.DatasetsList-itemCategory.is--rasterDataset { @include geometry-type-icon(-120px, -80px) }

.DatasetsList-itemStatus { color: $bannedColor }
}

Expand Down
32 changes: 29 additions & 3 deletions app/assets/stylesheets/new_common/map-card.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,37 @@ $opacityTransition: 250ms;
right: $sMargin-element;
}
.MapCard-headerFakeIcon {
width: 36px;
height: 36px;
font-size: 36px;
display: block;
width: 48px;
height: 48px;
border-radius: 50px;
line-height: 48px!important; // Overwritten by icon font style
font-size: 20px;
text-align:center;
border: 1px solid #EEE;
color: #EEE;
background: transparent;
}

.MapCard-headerFakeIcon.iconFont-People {
line-height: 35px!important;
font-size: 30px;
}
.MapCard-headerFakeIcon.iconFont-Snake {
line-height: 33px!important;
font-size: 30px;
}
.MapCard-headerFakeIcon.iconFont-Points {
line-height: 38px!important;
font-size: 24px;
}
.MapCard-headerFakeIcon.iconFont-Notes { font-size: 26px }
.MapCard-headerFakeIcon.iconFont-Mountain {
font-size: 28px;
line-height: 40px!important
}
.MapCard-headerFakeIcon.iconFont-Rectangles { font-size: 22px }

.MapCard-headerGraph {
position:absolute;
width: 70px;
Expand Down
2 changes: 1 addition & 1 deletion app/models/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def set_subject_permission(subject_id, access, type)

# @return User|nil
def owner
@owner ||= User.where(id:self.owner_id).first
@owner ||= User[self.owner_id] # See http://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/Caching.html
end

# @param value User
Expand Down
2 changes: 1 addition & 1 deletion app/models/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ def update_table_pg_stats
end

def owner
@owner ||= User.where(id: self.user_id).first
@owner ||= User[self.user_id]
end

def table_style
Expand Down
26 changes: 26 additions & 0 deletions app/models/table/user_table.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: UTF-8
require 'cartodb/per_request_sequel_cache'

# This class is intended to deal exclusively with storage
class UserTable < Sequel::Model
Expand Down Expand Up @@ -132,6 +133,20 @@ def self.find_by_identifier(user_id, identifier)
table
end

def self.from_map_id_key(map_id)
"UserTable:from_map_id:#{map_id}"
end

def self.from_map_id(map_id)
key = self.from_map_id_key(map_id)
user_table = PerRequestSequelCache.get(key)
if user_table.nil?
user_table = self[map_id: map_id]
PerRequestSequelCache.set(key, user_table, nil) unless user_table.nil?
end
user_table
end



# Hooks definition -----------------------------------------------------------
Expand Down Expand Up @@ -192,6 +207,17 @@ def after_destroy
super
service.after_destroy
end

def before_update
PerRequestSequelCache.delete(self.class.from_map_id_key(self.map_id))
super
end

def delete
PerRequestSequelCache.delete(self.class.from_map_id_key(self.map_id))
super
end

# --------------------------------------------------------------------------------


Expand Down
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: UTF-8
require 'cartodb/per_request_sequel_cache'
require_relative './user/user_decorator'
require_relative './user/oauths'
require_relative './synchronization/synchronization_oauth'
Expand Down Expand Up @@ -45,6 +46,7 @@ class User < Sequel::Model
plugin :validation_helpers
plugin :json_serializer
plugin :dirty
plugin :caching, PerRequestSequelCache

# Restrict to_json attributes
@json_serializer_opts = {
Expand Down
4 changes: 2 additions & 2 deletions app/models/visualization/relator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ def map
end

def user
@user ||= User.where(id: @user_id).first unless @user_id.nil?
@user ||= User[@user_id] unless @user_id.nil?
end

def table
return nil unless defined?(::Table)
return nil if map_id.nil?
@table ||= ::UserTable.where(map_id: map_id).first.try(:service)
@table ||= ::UserTable.from_map_id(map_id).try(:service)
end

def related_tables
Expand Down
2 changes: 1 addition & 1 deletion config/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#This file defines the version of the frontend code that is going to be loaded.
3.8.0
3.8.1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var pluralizeString = require('../../../../../view_helpers/pluralize_string');
module.exports = cdb.core.View.extend({

_TEXTS: {
item: _t('file')
item: _t('item')
},

options: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<div class="LayoutIcon ImportPanel-headerIcon">
<i class="iconFont iconFont-Gift"></i>
</div>
<h3 class="ImportPanel-headerTitle">Twitter connector</h3>
<p class="ImportPanel-headerDescription">Enable the Twitter connector in your account to create interactive maps <br/>
from Twitter activity related to your brand, event or any term you may be interested in.</p>
<h3 class="ImportPanel-headerTitle">Enable the Twitter Connector</h3>
<p class="ImportPanel-headerDescription">The Twitter Connector allows you to map twitter activity data related to your Brand, Event or any term you may be interested in.</p>
<a href="mailto:sales@cartodb.com" class="Button Button--invert ImportPanel-headerLink">
<span>ask for a demo</span>
</a>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<% if (state === 'selected') { %>
MailChimp campaign selected
<% } else { %>
Connect with MailChimp
Map your MailChimp Campaigns
<% } %>
</h3>
<p class="ImportPanel-headerDescription <% if (state === "error") { %>ImportPanel-headerDescription--negative<% } %>">
<% if (state === "idle") { %>
Log in with your account and select any of your campaigns.
Connect your MailChimp account to select any of your campaigns.
<% } %>
<% if (state === "error") { %>
We are sorry, can’t connect to your MailChimp account.
We are sorry, It has been an error while connecting to your MailChimp account.
<% } %>
<% if (state === "token") { %>
Checking Token.
Checking MailChimp Token.
<% } %>
<% if (state === "oauth") { %>
Requesting oAuth.
Expand All @@ -31,4 +31,4 @@
<i class="iconFont iconFont-ArrowPrev"></i>
</button>
<% } %>
<% } %>
<% } %>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = cdb.core.View.extend({
this.router.model.bind('change', this._onRouterChange, this);
this.collection.bind('reset', this._onDataFetched, this);
this.collection.bind('loading', this._onDataLoading, this);
this.collection.bind('add remove', this._onDataChange, this);
this.collection.bind('add', this._onDataChange, this);
this.collection.bind('error', function(col, e, opts) {
// Old requests can be stopped, so aborted requests are not
// considered as an error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ module.exports = cdb.core.View.extend({

viewModel.bind('DeleteItemsDone', function() {
this.user.fetch(); // needed in order to keep the "quota" synchronized
this.collection.fetch();
}, this);

var view = new DeleteItemsDialog({
Expand Down
2 changes: 1 addition & 1 deletion lib/assets/javascripts/cartodb/new_dashboard/list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = cdb.core.View.extend({

_initBinds: function() {
this.collection.bind('loading', this._onItemsLoading, this);
this.collection.bind('reset remove', this.render, this);
this.collection.bind('reset', this.render, this);
this.add_related_model(this.collection);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<%= content_type === 'datasets' && !canCreateDatasets ? 'is-disabled' : '' %>
<%= content_type === "maps" ? 'js-new_map' : 'js-new_dataset' %>
">
<span><%= content_type === "maps" ? 'Create new Map' : 'Connect Data' %></span>
<span><%= content_type === "maps" ? 'Create new Map' : 'New dataset' %></span>
</a>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,12 @@ describe('new_dashboard/content_controller_view', function() {
expect(this.view._isBlockEnabled('no_results')).toBeTruthy();
});

it('should show small_loader when collection has changed (add/remove)', function() {
it('should show small_loader when adding an element to the collection', function() {
this.router.model.set({ content_type: 'datasets' }, { silent: true });
this.collection.add(this.vis);
expect(this.view._isBlockEnabled('small_loader')).toBeTruthy();
this.router.model.set({ content_type: 'maps' });
expect(this.view._isBlockEnabled('small_loader')).toBeFalsy();
this.collection.remove(this.collection.at(0));
expect(this.view._isBlockEnabled('small_loader')).toBeTruthy();
});

});
Expand Down
18 changes: 18 additions & 0 deletions lib/cartodb/per_request_sequel_cache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# coding: UTF-8

module PerRequestSequelCache

def self.set(key, obj, ttl)
# Please note ttl is ignored
RequestStore.write(key, obj)
end

def self.get(key)
RequestStore.read(key)
end

def self.delete(key)
RequestStore.delete(key)
end

end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cartodb-ui",
"version": "3.8.0",
"version": "3.8.1",
"description": "CartoDB UI frontend",
"repository": {
"type": "git",
Expand Down

0 comments on commit f09e2c0

Please sign in to comment.