my_forum 0.0.1.beta54 → 0.0.1.beta55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/helpers/my_forum/forums_helper.rb +4 -4
- data/app/models/my_forum/forum.rb +9 -19
- data/lib/my_forum/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d60d076b33e39482575fa28df6a0cb00abd6fd0a
|
4
|
+
data.tar.gz: 1cc2d2d4d6de0fd303d9efb42460fb9747e0dc17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
6
|
-
read
|
5
|
+
unread = 'lada_logo_unread.jpg'
|
6
|
+
read = 'lada_logo.jpg'
|
7
7
|
|
8
|
-
display_as =
|
9
|
-
display_as =
|
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
|
-
|
24
|
-
|
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
|
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
|
|
data/lib/my_forum/version.rb
CHANGED