This repository has been archived by the owner. It is now read-only.

重构 tasks #34

Merged
merged 5 commits into from Apr 24, 2014

Conversation

Projects
None yet
2 participants
@tumayun
Contributor

tumayun commented Apr 24, 2014

  1. 之前需要在 initializer 里面预先加载用了 redis-search 的 model 才能运行 rake 创建索引, 现在去掉了这个依赖, task 自己去查找哪些 model 用了 redis-search, 然后创建索引.
  2. 给 Redis::Search::ClassMethods 添加了一个 redis_search_index_batch_create method, 创建当前 model 的索引.
  3. ActiveRecord::Base 改成字符串,这样运行时就不需要依赖 activerecord 了.
+
+ def redis_search_index_batch_create(batch_size = 1000, progressbar = false)
+ count = 0
+ if self.ancestors.collect { |klass| klass.to_s }.include?("ActiveRecord::Base")

This comment has been minimized.

Show comment Hide comment
@tumayun

tumayun Apr 24, 2014

Contributor

改成字符串形式,不依赖 activerecord

@tumayun

tumayun Apr 24, 2014

Contributor

改成字符串形式,不依赖 activerecord

This comment has been minimized.

Show comment Hide comment
@huacnlee

huacnlee Apr 24, 2014

Owner

这段很奇怪啊,如果多个 Model,里面有 ActiveRecord,有 Mongoid, 这里判断不是过不了?

@huacnlee

huacnlee Apr 24, 2014

Owner

这段很奇怪啊,如果多个 Model,里面有 ActiveRecord,有 Mongoid, 这里判断不是过不了?

This comment has been minimized.

Show comment Hide comment
@tumayun

tumayun Apr 24, 2014

Contributor

多个 Model ? 怎么会既有 ActiveRecord 又有 Mongoid 的 Model ?

@tumayun

tumayun Apr 24, 2014

Contributor

多个 Model ? 怎么会既有 ActiveRecord 又有 Mongoid 的 Model ?

This comment has been minimized.

Show comment Hide comment
@huacnlee

huacnlee Apr 24, 2014

Owner

有可能的,如果有出现,这行代码是有问题的

@huacnlee

huacnlee Apr 24, 2014

Owner

有可能的,如果有出现,这行代码是有问题的

@tumayun

This comment has been minimized.

Show comment Hide comment
@tumayun

tumayun Apr 24, 2014

Contributor

@huacnlee activesupport 也应该是 runtime dependency 吧!

Contributor

tumayun commented Apr 24, 2014

@huacnlee activesupport 也应该是 runtime dependency 吧!

README.md
```bash
-$ rake redis_search:index
+$ rake environment redis_search:index DIR=app/models BATCH=100

This comment has been minimized.

Show comment Hide comment
@huacnlee

huacnlee Apr 24, 2014

Owner

为何要加上 environment ?

@huacnlee

huacnlee Apr 24, 2014

Owner

为何要加上 environment ?

This comment has been minimized.

Show comment Hide comment
@tumayun

tumayun Apr 24, 2014

Contributor

@huacnlee 额 不需要, 应该去掉. 这里是因为一开始 task 里面我没有加 environment, 后面加上了,忘了修改这里

@tumayun

tumayun Apr 24, 2014

Contributor

@huacnlee 额 不需要, 应该去掉. 这里是因为一开始 task 里面我没有加 environment, 后面加上了,忘了修改这里

@huacnlee

This comment has been minimized.

Show comment Hide comment
@huacnlee

huacnlee Apr 24, 2014

Owner

activesupport 在 runtime 是必要的

Owner

huacnlee commented Apr 24, 2014

activesupport 在 runtime 是必要的

@tumayun

This comment has been minimized.

Show comment Hide comment
@tumayun

tumayun Apr 24, 2014

Contributor

@huacnlee 那你觉得怎么弄比较好?

Contributor

tumayun commented Apr 24, 2014

@huacnlee 那你觉得怎么弄比较好?

@tumayun

This comment has been minimized.

Show comment Hide comment
@tumayun

tumayun Apr 24, 2014

Contributor

@huacnlee 我始终觉得这种情况一般不会出现, 也不应该出现

Contributor

tumayun commented Apr 24, 2014

@huacnlee 我始终觉得这种情况一般不会出现, 也不应该出现

@huacnlee

This comment has been minimized.

Show comment Hide comment
@huacnlee

huacnlee Apr 24, 2014

Owner

@tumayun 哦,我理解错了,那个地方是判断集成的类

Owner

huacnlee commented Apr 24, 2014

@tumayun 哦,我理解错了,那个地方是判断集成的类

huacnlee added a commit that referenced this pull request Apr 24, 2014

@huacnlee huacnlee merged commit e159621 into huacnlee:master Apr 24, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@tumayun

This comment has been minimized.

Show comment Hide comment
@tumayun

tumayun Apr 24, 2014

Contributor

@huacnlee 哦 我说呢, 你在美国好潇洒呀, 有没有打算回来和给我们分享下呀

Contributor

tumayun commented Apr 24, 2014

@huacnlee 哦 我说呢, 你在美国好潇洒呀, 有没有打算回来和给我们分享下呀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.