libertree-model 0.9.15 → 0.9.16

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libertree/model/pool.rb +20 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 778a2a58bc810cdc33a1b4074a3684bb8fba3357cb9356e25177c3d173b857ce
4
- data.tar.gz: 7b51c70569f2ad8489d2db916c0e900912251add97b67d648d2c4fb34a247476
3
+ metadata.gz: 1d084f6691620280affdb0defc6e7ab1d2f7c0b3a7966add5adee31907afb088
4
+ data.tar.gz: 7a521d8ba93a593d3d07b8fcf91489b45a6df057d7a557777d72ced929fdd9d8
5
5
  SHA512:
6
- metadata.gz: 5bd65df3ffb95e07a3a1b28aa66a4382be78e59b04ab47477ac977b00e5cf4ae3bca28ac5c4549cfc762c9c274e46e027e3c1a4f6de50148a42c5eb813c6ae21
7
- data.tar.gz: 183106c64a266df43e990875c7d8455f0a62575adf5e93f738244b71b6af664bd18e25332ff46eb56183de2dd44c6920a401c350f0748c5abef47bc4ea2d54ce
6
+ metadata.gz: 8dc52396d815bd7e0b76d3212bc30151ded903bb1a285b2858ed1482857191eaf2cea655604c39cdde58cb07c2731f9c8a425e412d67c262c726c438c142e247
7
+ data.tar.gz: 3c1d4b88e5962951d6e438af844527c5ba5ffb2f1f86abad523d33f139642d6c7f8da158fea829021e3919e38e10e5ac03fa01a3aed9f3e0e573c017559d85f3
@@ -76,21 +76,29 @@ module Libertree
76
76
  def posts( opts = {} )
77
77
  limit = opts.fetch(:limit, 30)
78
78
  time = Time.at( opts.fetch(:time, Time.now.to_f) ).strftime("%Y-%m-%d %H:%M:%S.%6N%z")
79
- time_clause = if opts[:newer]
80
- proc { time_created > time }
81
- else
82
- proc { time_created < time }
83
- end
84
-
85
- res = Post.qualify.
86
- join(:pools_posts, :post_id=>:id).
87
- where(&time_clause).
88
- where(:pool_id => self.id).
89
- reverse_order(Sequel.qualify(:posts, :id)).
90
- limit(limit)
79
+ if opts[:newer]
80
+ time_clause = proc { time_created > time }
81
+ else
82
+ time_clause = proc { time_created < time }
83
+ end
84
+
85
+ order_by_updated = opts.fetch(:order_by_updated, false)
86
+ if order_by_updated
87
+ order = Sequel.lit("GREATEST(posts.time_commented, posts.time_updated)")
88
+ else
89
+ order = Sequel.qualify(:posts, :id)
90
+ end
91
+
92
+ res = Post.qualify
93
+ .join(:pools_posts, post_id: :id)
94
+ .where(&time_clause)
95
+ .where(pool_id: self.id)
96
+ .reverse_order(order)
97
+ .limit(limit)
91
98
 
92
99
  # optionally restrict to Internet visible posts
93
100
  res = res.where(visibility: 'internet') if opts[:public]
101
+
94
102
  res
95
103
  end
96
104
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libertree-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.15
4
+ version: 0.9.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pistos
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-18 00:00:00.000000000 Z
12
+ date: 2020-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-oembed