my_forum 0.0.1.beta54 → 0.0.1.beta55

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05f5add2d9ed60e6426fbe2fd3397d433a97240a
4
- data.tar.gz: 817168a8cf5afe3a4c79dc01088ad4d9df1ef894
3
+ metadata.gz: d60d076b33e39482575fa28df6a0cb00abd6fd0a
4
+ data.tar.gz: 1cc2d2d4d6de0fd303d9efb42460fb9747e0dc17
5
5
  SHA512:
6
- metadata.gz: adb0e2d983a36c3dfe32409b980892cae0e0d0bd33a615455c8c7f1561c8fe8a41b7af462e01d0e500b7d5351f79a27a04cd2c51f64f6747e4c6509e57983b34
7
- data.tar.gz: 5b2be6aa9eee71f98ac0f9aac8b922afa3a542378e839b4517f60564c7d488ec9456b5eb575d67fce5e31ec5187630b2e3399705a1d94aaf72c8c42a66cf0609
6
+ metadata.gz: 1e1b855277fa1dec912d8e7c394579e55b65c285c1216edafe732762393a8121a7cbda0cce01ce8aae703cc345fff7dd6fb340a3a144971e26eca9497d6e05cc
7
+ data.tar.gz: 3a6f0d50d345965110223814ad1d4617b28048af488a241021f5dde12942b11f944e977a9ae10358aa6e0197f81090f074a4c37e1300867a562aed51fdad75d0
@@ -2,11 +2,11 @@ module MyForum
2
2
  module ForumsHelper
3
3
 
4
4
  def forum_status_img(forum)
5
- unread = 'lada_logo_unread.jpg'
6
- read = 'lada_logo.jpg'
5
+ unread = 'lada_logo_unread.jpg'
6
+ read = 'lada_logo.jpg'
7
7
 
8
- display_as = unread
9
- display_as = read unless current_user && forum.has_unread_posts?(current_user)
8
+ display_as = read
9
+ display_as = unread if forum.has_unread_posts?(current_user)
10
10
 
11
11
  image_tag(display_as, width: '66px')
12
12
  end
@@ -4,28 +4,18 @@ module MyForum
4
4
  has_many :topics
5
5
  has_many :posts
6
6
 
7
- # TODO: Deprecated
8
- # def latest_topic_info
9
- # Topic.find_by_sql("
10
- # SELECT
11
- # my_forum_topics.name AS topic_name,
12
- # my_forum_topics.forum_id,
13
- # my_forum_topics.id,
14
- # my_forum_topics.latest_post_created_at AS post_created_at,
15
- # my_forum_topics.latest_post_login AS user_login
16
- # FROM my_forum_topics
17
- # WHERE my_forum_topics.forum_id = #{self.id}
18
- # LIMIT 1
19
- # ").first
20
- # end
21
-
22
7
  def has_unread_posts?(current_user)
23
- latest_post_ids = self.topics.where('updated_at >= ?', current_user.created_at).pluck(:latest_post_id)
24
- read_log = LogReadMark.where("user_id = ? AND post_id IN (?)", current_user.id, latest_post_ids).count
8
+ return false unless current_user
9
+
10
+ latest_post_ids = self.topics.where('latest_post_created_at >= ?', current_user.created_at).pluck(:latest_post_id)
11
+ read_log = LogReadMark.where("user_id = ? AND post_id IN (?)", current_user.id, latest_post_ids).pluck(:post_id)
25
12
 
26
- latest_post_ids.length != read_log
13
+ !(latest_post_ids - read_log).empty?
14
+ #latest_post_ids.length != read_log
15
+ #read_log >= latest_post_ids.length
27
16
  end
28
17
 
18
+ # Forum index page
29
19
  def topics_with_latest_post_info(page: 0, per_page: 30)
30
20
  Topic.paginate_by_sql("
31
21
  SELECT
@@ -34,7 +24,7 @@ module MyForum
34
24
  my_forum_topics.latest_post_login AS last_post_user_login
35
25
  FROM my_forum_topics
36
26
  WHERE my_forum_topics.forum_id = #{self.id} AND my_forum_topics.deleted IS FALSE
37
- ORDER BY my_forum_topics.pinned, my_forum_topics.latest_post_created_at DESC
27
+ ORDER BY my_forum_topics.pinned DESC, my_forum_topics.latest_post_created_at DESC
38
28
  ", page: page, per_page: per_page)
39
29
  end
40
30
 
@@ -1,3 +1,3 @@
1
1
  module MyForum
2
- VERSION = "0.0.1.beta54"
2
+ VERSION = "0.0.1.beta55"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_forum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta54
4
+ version: 0.0.1.beta55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaly Omelchenko