postjob 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ac14950c33a8d27f1b7fec8de0781559f6a5cc1
4
- data.tar.gz: e3e91f7b243cf9bb77bd7790a69023735e6bc51d
3
+ metadata.gz: 04c8dbb68c7f61be34b8bfe642fdd6ce04933e08
4
+ data.tar.gz: 355aca75cf91e2107d850163802ab87aabf94126
5
5
  SHA512:
6
- metadata.gz: fbf45a53d92ecf44b380c0e13894da8a95f8e0da22adcfdf408db798bc8d9fef7f3b7e4ae2d671d6b5029a537c06e5c0a893248f4432fbb44d62cbf10f2ad830
7
- data.tar.gz: 664a10208ac94e5b6ae0700c193c111497b8f42c75174a22e6bb26dd838afe826639bbb59df0ad878caae88d1dcf09d1e69701ff98ca6db12be79c3c60520a8e
6
+ metadata.gz: 50c02c184aab359a4c67d5b4b853560aac3a54636ed603cbfd7c161b61057c807d9ea0a752bce79a4c57c77f0f4841c4d7b5cbe33535bfafb42d2c0b8a50e46b
7
+ data.tar.gz: 56e861011da77177e1e8b147ff2447a26f292b8bdeceeec117dfd2b979cd4ca0449e493c2f00f4cce3cecceb99b2677f2fce177aaca241c61997082d7a6764d5
@@ -1,4 +1,16 @@
1
1
  module Postjob::CLI
2
+ # Resolve a job by token
3
+ def job_resolve(token, result)
4
+ connect_to_database!
5
+ Postjob.resolve(token: token, result: result)
6
+ end
7
+
8
+ # # Fail a job by token
9
+ # def job_resolve(token, result)
10
+ # connect_to_database!
11
+ # Postjob.resolve(token: token, result: result)
12
+ # end
13
+
2
14
  # Enqueues a workflow
3
15
  #
4
16
  # Adds a workflow to the job table, with name <workflow> and the given
@@ -7,7 +7,7 @@ module Postjob::CLI
7
7
  def ps_query(tags:, limit:)
8
8
  sql = <<-SQL
9
9
  SELECT
10
- id,
10
+ postjobs.id,
11
11
  full_id,
12
12
  workflow
13
13
  || (CASE WHEN workflow_version != '' THEN '@' ELSE '' END)
@@ -20,7 +20,7 @@ module Postjob::CLI
20
20
  COALESCE((results->0)::varchar, error_message) AS result,
21
21
  next_run_at,
22
22
  next_run_at - (now() at time zone 'utc') AS next_run_in,
23
- to_char(EXTRACT(EPOCH FROM (now() at time zone 'utc') - created_at), '999999999.99') AS age,
23
+ to_char(EXTRACT(EPOCH FROM (now() at time zone 'utc') - postjobs.created_at), '999999999.99') AS age,
24
24
  CASE WHEN processing_started_at IS NOT NULL THEN
25
25
  format(
26
26
  '%s/%s',
@@ -30,7 +30,7 @@ module Postjob::CLI
30
30
  END AS processing,
31
31
  COALESCE(processing_client, '') || COALESCE('/' || processing_client_identifier, '') AS worker,
32
32
  tags
33
- FROM postjob.postjobs
33
+ FROM postjob.postjobs AS postjobs
34
34
  SQL
35
35
 
36
36
  scope = Simple::SQL::Scope.new(sql)
@@ -105,8 +105,12 @@ module Postjob::CLI
105
105
  def ps_show(id, *ids)
106
106
  connect_to_database!
107
107
 
108
- scope = Simple::SQL::Scope.new("SELECT * FROM postjob.postjobs")
109
- scope = scope.where("id = ANY(?)", parse_ids(id, *ids))
108
+ scope = Simple::SQL::Scope.new <<~SQL
109
+ SELECT postjobs.*, tokens.token
110
+ FROM postjob.postjobs AS postjobs
111
+ LEFT JOIN postjob.tokens AS tokens ON tokens.postjob_id=postjobs.id
112
+ SQL
113
+ scope = scope.where("postjobs.id = ANY(?)", parse_ids(id, *ids))
110
114
 
111
115
  Simple::SQL.all(scope, into: Postjob::Job) do |job|
112
116
  pp job
data/lib/postjob.rb CHANGED
@@ -162,6 +162,8 @@ module Postjob
162
162
 
163
163
  def resolve(token:, result:)
164
164
  job = Queue.find_job_by_token(token)
165
+ raise "No job with token #{token}" unless job
166
+
165
167
  Queue.set_job_result job, result, version: nil
166
168
  end
167
169
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-30 00:00:00.000000000 Z
11
+ date: 2018-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec