litequeue 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: f97ba4711413d74fd5fc46de7253269e5b339699ee7976a75a99aa848005bd05
4
- data.tar.gz: f01ca5ac9975a21e6c51e2d48367d622024ae3e8b894216e6ea75403c6f700fa
3
+ metadata.gz: 975ed284b758c73f3ac99d5874c05fea38eb8c25bb36221b56f3e778b3f8fc08
4
+ data.tar.gz: fcb2a7662243851c7dcc62ea6346b0a1cbd591330c2d0883737609ff7996c260
5
5
  SHA512:
6
- metadata.gz: b770e17b77f912b995afd83a78adde03352be6fbfd6cce62bdb798d53babf61039076f0116de757f10ab97113d1f484a9341025b21a88115af6f3b4c8acd43fb
7
- data.tar.gz: 3ee4953f64da9a77d00132a62c85ec598c018be999f6b958a02d9fee4f2fc38e9f3fd85ab53fb4aeaae16f2a9331eba90c186ac60106aeaf30dd081b918b991e
6
+ metadata.gz: 17cb8fc124f2b14ff43f10e2281af2d33e60b684a2dcea9c735e15798efa3790976cda508d8e9d5a1ef2816b4322bf9c906b53156a65c68987cb8d1d29d82fcd
7
+ data.tar.gz: 10cea9107216cbbb56a2fe2e7647c2a5830acd74ae8840817dd6dd9aa717124588dd61cbb2d2ba51b4adcb39661c353c36ff7c10a1e6d4551feb76c560b4fbab
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2023-08-11
4
+
5
+ - Update statements to work with SQLite versions that don't support `UNIXEPOCH('subsec')``
6
+
3
7
  ## [0.2.0] - 2023-08-11
4
8
 
5
9
  - Initial release of usable code
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- litequeue (0.2.0)
4
+ litequeue (0.2.1)
5
5
  litedb (>= 0.2.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Litequeue
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/litequeue.svg)](https://rubygems.org/gems/litequeue)
4
+ [![Gem Downloads](https://img.shields.io/gem/dt/litequeue)](https://rubygems.org/gems/litequeue)
5
+ ![Tests](https://github.com/litestack-ruby/litequeue/actions/workflows/main.yml/badge.svg)
6
+ ![Coverage](https://img.shields.io/badge/code_coverage-100%25-brightgreen)
7
+
3
8
  TODO: Delete this and the text below, and describe your gem
4
9
 
5
10
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/litequeue`. To experiment with that code, run `bin/console` for an interactive prompt.
data/Rakefile CHANGED
@@ -9,6 +9,34 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.test_files = FileList["test/**/test_*.rb"]
10
10
  end
11
11
 
12
+ desc "Update the README code coverage badge"
13
+ task :update_readme_coverage_badge do
14
+ require "json"
15
+
16
+ next unless File.exist?("coverage/.last_run.json")
17
+
18
+ last_run_coverage = JSON.load_file("coverage/.last_run.json")
19
+ line_coverage = last_run_coverage.dig("result", "line")
20
+ branch_coverage = last_run_coverage.dig("result", "branch")
21
+ average_coverage = [(branch_coverage * 1), (line_coverage * 1.5)].sum.fdiv(2.5).round
22
+ badge_color = if average_coverage >= 75
23
+ :brightgreen
24
+ else
25
+ :red
26
+ end
27
+
28
+ coverage_badge_re = /!\[Coverage\]\(https:\/\/img.shields.io\/badge\/code_coverage-(.*?)\)/
29
+ last_run_coverage_badge = "![Coverage](https://img.shields.io/badge/code_coverage-#{average_coverage}%25-#{badge_color})"
30
+
31
+ new_readme = File.read("README.md").gsub(coverage_badge_re, last_run_coverage_badge)
32
+
33
+ File.write("README.md", new_readme)
34
+
35
+ puts "Updated README code coverage badge to show #{average_coverage}% coverage."
36
+ end
37
+
38
+ task cov: %i[test update_readme_coverage_badge]
39
+
12
40
  require "standard/rake"
13
41
 
14
42
  task default: %i[test standard]
@@ -1,6 +1,6 @@
1
1
  push: >
2
2
  INSERT INTO queue(id, name, fire_at, value)
3
- VALUES (HEX(RANDOMBLOB(32)), $1, (UNIXEPOCH('subsec') + $2), $3)
3
+ VALUES (HEX(RANDOMBLOB(32)), $1, (IFNULL(UNIXEPOCH('subsec'), UNIXEPOCH()) + $2), $3)
4
4
  RETURNING id, name;
5
5
 
6
6
  pop: >
@@ -10,7 +10,7 @@ pop: >
10
10
  IN (
11
11
  SELECT name, fire_at, id FROM queue
12
12
  WHERE name = IFNULL($1, 'default')
13
- AND fire_at <= (UNIXEPOCH('subsec'))
13
+ AND fire_at <= IFNULL(UNIXEPOCH('subsec'), UNIXEPOCH())
14
14
  ORDER BY fire_at ASC
15
15
  LIMIT IFNULL($2, 1)
16
16
  )
@@ -18,7 +18,7 @@ pop: >
18
18
 
19
19
  repush: >
20
20
  INSERT INTO queue(id, name, fire_at, value)
21
- VALUES ($1, $2, (UNIXEPOCH('subsec') + $3), $4)
21
+ VALUES ($1, $2, (IFNULL(UNIXEPOCH('subsec'), UNIXEPOCH()) + $3), $4)
22
22
  RETURNING name;
23
23
 
24
24
  delete: >
@@ -40,9 +40,9 @@ info: >
40
40
  SELECT
41
41
  name,
42
42
  COUNT(*) AS count,
43
- AVG(UNIXEPOCH('subsec') - created_at) AS avg,
44
- MIN(UNIXEPOCH('subsec') - created_at) AS min,
45
- MAX(UNIXEPOCH('subsec') - created_at) AS max
43
+ AVG(IFNULL(UNIXEPOCH('subsec'), UNIXEPOCH()) - created_at) AS avg,
44
+ MIN(IFNULL(UNIXEPOCH('subsec'), UNIXEPOCH()) - created_at) AS min,
45
+ MAX(IFNULL(UNIXEPOCH('subsec'), UNIXEPOCH()) - created_at) AS max
46
46
  FROM queue
47
47
  GROUP BY name
48
48
  ORDER BY count DESC;
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Litequeue
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litequeue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohamed Hassan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-08-11 00:00:00.000000000 Z
12
+ date: 2023-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: litedb