Add view count.

This commit is contained in:
邱博亞 2024-07-21 15:23:29 +08:00
parent 0265cbc9bd
commit d202a8ad0a
3 changed files with 11 additions and 1 deletions

View File

@ -257,8 +257,13 @@ class UniversalTablesController < ApplicationController
} if text != "" } if text != ""
end end
sorted = rows.sort{ |k,v| k["order"] <=> v["order"] } sorted = rows.sort{ |k,v| k["order"] <=> v["order"] }
entry.inc(view_count: 1)
{ {
"entry" => sorted "entry" => sorted,
"extras" => {
"view_count_head": I18n.t("view_count"),
"view_count" => entry.view_count
}
} }
end end
end end

View File

@ -5,6 +5,7 @@ class TableEntry
attr_accessor :sort_value attr_accessor :sort_value
field :sort_number, type: Integer field :sort_number, type: Integer
field :view_count, type: Integer, default: 0
has_many :column_entries, :dependent => :destroy has_many :column_entries, :dependent => :destroy
belongs_to :u_table, index: true belongs_to :u_table, index: true

View File

@ -19,3 +19,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="view_count pull-right">
<i class="fa fa-eye">{{view_count_head}}:</i>
<span class="view-count">{{view_count}}</span>
</div>