Module: Card::Set::Self::Admin::HtmlFormat

Extended by:
AbstractFormat
Defined in:
tmpsets/set/mod002-admin/self/admin.rb

Instance Method Summary collapse

Instance Method Details

#cache_statsObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 78

def cache_stats
  [
    { title: "solid cache",
      count: solid_cache_count, unit: " cards",
      link_text: "clear solid cache",
      task: "clear_solid_cache" },
    { title: "machine cache",
      count: machine_cache_count, unit: " cards",
      link_text: "clear machine cache",
      task: "clear_machine_cache" }
  ]
  # return stats unless Card.config.view_cache#
  # stats << { title: "view cache",
  #            count: Card::View,
  #            link_text: "clear view cache",
  #            task: "clear_view_cache" }
end

#card_statsObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 63

def card_stats
  [
    { title: "cards",
      count: Card.where(trash: false) },
    { title: "actions",
      count: Card::Action },
    #  link_text: "clear history",
    #  task: "clear_history" },
    { title: "references",
      count: Card::Reference }
    # link_text: "repair all",
    # task: "repair_references" }
  ]
end

#count(counter) ⇒ Object



119
120
121
122
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 119

def count counter
  counter = counter.call if counter.is_a?(Proc)
  counter.respond_to?(:count) ? counter.count : counter
end


132
133
134
135
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 132

def delete_sessions_link months
  link_to_card :admin, months, path: { action: :update, months: months,
                                       task: "delete_old_sessions" }
end

#machine_cache_countObject



128
129
130
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 128

def machine_cache_count
  Card::Virtual.where(right_id: MachineCacheID).count
end

#memory_statsObject



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 96

def memory_stats
  oldmem = session[:memory]
  session[:memory] = newmem = card.profile_memory
  stats = [
    { title: "memory now",
      count: newmem, unit: "M",
      link_text: "clear cache", task: "clear_cache" }
  ]
  return stats unless oldmem
  stats << { title: "memory prev", count: oldmem, unit: "M" }
  stats << { title: "memory diff", count: newmem - oldmem, unit: "M" }
  stats
end

#solid_cache_countObject



124
125
126
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 124

def solid_cache_count
  Card.search right: { codename: "solid_cache" }, return: "count"
end

#stat_row(args = {}) ⇒ Object



110
111
112
113
114
115
116
117
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 110

def stat_row args={}
  res = [(args[:title] || "")]
  res << "#{count(args[:count])}#{args[:unit]}"
  return res unless args[:task]
  res << link_to_card(:admin, (args[:link_text] || args[:task]),
                      path: { action: :update, task: args[:task] })
  res
end