trogdir_models 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trogdir/sync_log.rb +3 -1
- data/lib/trogdir/syncinator.rb +32 -1
- data/lib/trogdir_models/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81d87720d663131edba6072fab87909a42d4d377
|
4
|
+
data.tar.gz: 4dd28c82748f6bf10f83dc259b3cce4f69a36b96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28dd7d986223671e7f0a4762c0ed893075fa862a020a12ce9ba18b946c6c0f5bebea9171643f81bae5122976548e2f17ebee9de58c559480909f591908f08f1d
|
7
|
+
data.tar.gz: a8d7e94a1c1e4669b89d59587350b75a2b015d2e0c33ce4c6adf96839ea50a721c9db6e89576a5618a1d19ef215a36503d5449e2ce131da48c0c0cb2a9bf48f9
|
data/lib/trogdir/sync_log.rb
CHANGED
data/lib/trogdir/syncinator.rb
CHANGED
@@ -23,8 +23,39 @@ class Syncinator
|
|
23
23
|
name
|
24
24
|
end
|
25
25
|
|
26
|
+
def startable_changesets(retry_after = nil)
|
27
|
+
retry_after ||= 1.hour.ago
|
28
|
+
|
29
|
+
Changeset.where(
|
30
|
+
:'change_syncs.syncinator_id' => id
|
31
|
+
).or(
|
32
|
+
{:'change_syncs.sync_logs'.with_size => nil},
|
33
|
+
{:'change_syncs.sync_logs'.elem_match => {:started_at.lt => retry_after, succeeded_at: nil}}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def start!(changeset)
|
38
|
+
return false unless change_sync = change_sync_for(changeset)
|
39
|
+
|
40
|
+
change_sync.sync_logs.create! started_at: Time.now
|
41
|
+
end
|
42
|
+
|
43
|
+
def error!(sync_log, message)
|
44
|
+
sync_log.update_attributes errored_at: Time.now, message: message
|
45
|
+
sync_log
|
46
|
+
end
|
47
|
+
|
48
|
+
def finish!(sync_log, action, message = nil)
|
49
|
+
sync_log.update_attributes succeeded_at: Time.now, action: action, message: message
|
50
|
+
sync_log
|
51
|
+
end
|
52
|
+
|
26
53
|
private
|
27
54
|
|
55
|
+
def change_sync_for(changeset)
|
56
|
+
changeset.change_syncs.find_by(syncinator: self)
|
57
|
+
end
|
58
|
+
|
28
59
|
def set_default_slug
|
29
60
|
self.slug ||= name.parameterize
|
30
61
|
end
|
@@ -36,4 +67,4 @@ class Syncinator
|
|
36
67
|
def set_secret_key
|
37
68
|
self.secret_key = ApiAuth.generate_secret_key
|
38
69
|
end
|
39
|
-
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trogdir_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Crownoble
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api-auth
|