subapp_model 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/subapp_model/selected_albums.rb +44 -0
- data/lib/subapp_model/selected_albums_relation.rb +28 -0
- data/lib/subapp_model/version.rb +1 -1
- metadata +3 -8
- data/Gemfile +0 -5
- data/LICENSE.txt +0 -22
- data/README.md +0 -29
- data/Rakefile +0 -1
- data/ctags.rb +0 -3
- data/lib/.DS_Store +0 -0
- data/subapp_model.gemspec +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f94e2ad3b068a5babaead4901054ee590c3ea549
|
4
|
+
data.tar.gz: c1afa45138b300257f36fd6481f49840b3c5c89c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a9107c05e746545c530857b988e4e8b5ed1b0c355e42f3fee6da205cdd088418934141e3007956b09d82e9a1d1d1ffd7751138b4abbfb626b250ed43d15e80c
|
7
|
+
data.tar.gz: edd4fc4f6f63389b7ec27c8f728f6cb55803f8f2457dde85250afdd97350f2f908c3d1a8e1b065e213c89f09971c276536e44a3e259950719b50b4173ccb361a
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#-*- encoding: utf-8 -*-
|
2
|
+
class SelectedAlbums < ActiveRecord::Base
|
3
|
+
establish_connection SUBAPP_DB
|
4
|
+
self.table_name = 'tb_selected_albums' # 子App分类类型
|
5
|
+
attr_accessible :title, :tags, :album_extra_tags, :extra_tags, :order_num, :cover_path, :category_id, :last_uptrack_at, :created_at, :updated_at
|
6
|
+
|
7
|
+
def self.get(selected_album_cache, id)
|
8
|
+
selected_album = selected_album_cache.get(id)
|
9
|
+
selected_album = self.find(id) if selected_album.nil?
|
10
|
+
selected_album_cache.put(selected_album) unless selected_album.nil?
|
11
|
+
selected_album
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.mget(selected_album_cache, ids)
|
15
|
+
selected_albums = selected_album_cache.multi_get(ids)
|
16
|
+
fetch_ids_hash= {}
|
17
|
+
fetch_ids = []
|
18
|
+
selected_albums.each_with_index do |selected_album, i|
|
19
|
+
if selected_album.nil?
|
20
|
+
fetch_ids << ids[i]
|
21
|
+
fetch_ids_hash[ids[i]] = i
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if fetch_ids.length > 0
|
26
|
+
selected_albums_not_hit = self.find(fetch_ids)
|
27
|
+
cached_selected_albums = []
|
28
|
+
|
29
|
+
selected_albums_not_hit.each_with_index do |selected_album, i|
|
30
|
+
if !selected_album.nil?
|
31
|
+
selected_albums[fetch_ids_hash[selected_album.id]] = selected_album
|
32
|
+
cached_selected_albums << selected_album
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
selected_album_cache.multi_put(cached_selected_albums) if cached_selected_albums.length > 0
|
37
|
+
end
|
38
|
+
selected_albums
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.disable_cache(selected_album_cache, id)
|
42
|
+
selected_album_cache.evict(id)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#-*- encoding: utf-8 -*-
|
2
|
+
class SelectedAlbumsRelation < ActiveRecord::Base
|
3
|
+
establish_connection SUBAPP_DB
|
4
|
+
self.table_name = 'tb_selected_albums_relation' # 子App分类类型
|
5
|
+
attr_accessible :selected_id, :album_id, :updated_at
|
6
|
+
|
7
|
+
def self.get_album_ids(list_ids_cache, selected_album, page, limit)
|
8
|
+
id = selected_album.id
|
9
|
+
album_ids = nil
|
10
|
+
if page == 1
|
11
|
+
album_ids = list_ids_cache.get(id, page, limit)
|
12
|
+
end
|
13
|
+
|
14
|
+
if album_ids.nil? || album_ids.length == 0
|
15
|
+
select = "album_id"
|
16
|
+
album_relations = self.select(select).where(:selected_id=>id).order("field(album_id,#{selected_album.order_num})").offset((page-1)*limit).limit(limit)
|
17
|
+
album_ids = album_relations.collect{|album_relation| album_relation.album_id unless album_relation.nil?}
|
18
|
+
if page == 1 && album_ids.length > 0
|
19
|
+
list_ids_cache.put(id, album_ids)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
album_ids
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.disable_cache(list_ids_cache, id)
|
26
|
+
list_ids_cache.evict(id)
|
27
|
+
end
|
28
|
+
end
|
data/lib/subapp_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subapp_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gavin
|
@@ -45,12 +45,6 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- Gemfile
|
49
|
-
- LICENSE.txt
|
50
|
-
- README.md
|
51
|
-
- Rakefile
|
52
|
-
- ctags.rb
|
53
|
-
- lib/.DS_Store
|
54
48
|
- lib/subapp_model.rb
|
55
49
|
- lib/subapp_model/app.rb
|
56
50
|
- lib/subapp_model/app_ad.rb
|
@@ -62,6 +56,8 @@ files:
|
|
62
56
|
- lib/subapp_model/app_material.rb
|
63
57
|
- lib/subapp_model/app_tag.rb
|
64
58
|
- lib/subapp_model/font.rb
|
59
|
+
- lib/subapp_model/selected_albums.rb
|
60
|
+
- lib/subapp_model/selected_albums_relation.rb
|
65
61
|
- lib/subapp_model/skin.rb
|
66
62
|
- lib/subapp_model/sub_app_advertisement.rb
|
67
63
|
- lib/subapp_model/sub_app_log.rb
|
@@ -69,7 +65,6 @@ files:
|
|
69
65
|
- lib/subapp_model/subapp_push_app.rb
|
70
66
|
- lib/subapp_model/subapp_push_msg.rb
|
71
67
|
- lib/subapp_model/version.rb
|
72
|
-
- subapp_model.gemspec
|
73
68
|
homepage: ''
|
74
69
|
licenses:
|
75
70
|
- MIT
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 TODO: Write your name
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# SubappModel
|
2
|
-
|
3
|
-
TODO: Write a gem description
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'subapp_model'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install subapp_model
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/ctags.rb
DELETED
data/lib/.DS_Store
DELETED
Binary file
|
data/subapp_model.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require 'subapp_model/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "subapp_model"
|
7
|
-
spec.version = SubappModel::VERSION
|
8
|
-
spec.authors = ["gavin"]
|
9
|
-
spec.email = ["gavin@ximalaya.com"]
|
10
|
-
spec.description = %q{subapp_model}
|
11
|
-
spec.summary = %q{subapp_model}
|
12
|
-
spec.homepage = ""
|
13
|
-
spec.license = "MIT"
|
14
|
-
spec.rubyforge_project = "subapp_model"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
end
|