Class: Jobs::EnsureDbConsistency

Inherits:
Scheduled show all
Defined in:
app/jobs/scheduled/ensure_db_consistency.rb

Overview

various consistency checks

Instance Method Summary collapse

Methods inherited from Scheduled

#perform

Methods inherited from Base

acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately

Instance Method Details

#execute(args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/jobs/scheduled/ensure_db_consistency.rb', line 8

def execute(args)
  start_measure

  # we don't want to have a situation where Jobs::Badge or stuff like that is attempted to be run
  # so we always prefix with :: to ensure we are running models

  [
    ::UserVisit,
    ::Group,
    ::Notification,
    ::TopicFeaturedUsers,
    ::PostRevision,
    ::Topic,
    ::Badge,
    ::CategoryUser,
    ::UserOption,
    ::Tag,
    ::CategoryTagStat,
    ::User,
    ::UserAvatar,
    ::UserEmail,
    ::Category,
    ::TopicThumbnail,
  ].each do |klass|
    klass.ensure_consistency!
    measure(klass)
  end

  UserAction.ensure_consistency!(13.hours.ago)
  measure(UserAction)

  UserStat.ensure_consistency!(13.hours.ago)
  measure(UserStat)

  GroupUser.ensure_consistency!(13.hours.ago)
  measure(GroupUser)

  Rails.logger.debug(format_measure)
  nil
end