alembic 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ca021353e957d6825f69057128a3a92f154f048b89a2e26d94ff285f8b8a372
4
- data.tar.gz: b6767fc9d270afb8de1ddb605e7f099904c64ab77af5da56f39591d82da62151
3
+ metadata.gz: e81efddf247765d5a20f6134dc45c4f3d66199cf3e66c9247266614b7bce598a
4
+ data.tar.gz: 60fb3ffd6451a586ef2e575006821e3fc92fcdbeb15d4295958c449db38beebc
5
5
  SHA512:
6
- metadata.gz: 6f676f812331f3cd69ab8e8ff8c38cbabcfe66d4527ac7f8a1d18f81b7d9fa24803421ca57d3948cd8a0bbf2fd2e3de44ba7faa07484991d9975179ba31fbb9d
7
- data.tar.gz: '009c8f96d9a90ca499cb9537a2e134a30290b21610b3ceeda23c57a115dcdd60db81773818cd9357a5ca8ccb00be31478efa1327e6baa83ca808d2b4b880b439'
6
+ metadata.gz: 28126057cb83d2c6e1ac4b0054d8e1e31a822121ccdcec366c6deb2cdacd4c289ad281851a888c7ea713a7158786e1fbfb5fe4edb1544c9d74a288cbffdeb30b
7
+ data.tar.gz: '0397881ea22eccbe986ac55b927b934eef07be846de292894016b651a2289c0eda40018ec7e6ec76dc983673523c8bc260290a4fd20bea99c557d615905cd4d6'
@@ -21,7 +21,7 @@ module Alembic
21
21
 
22
22
  def update
23
23
  details = params.require(:flow)
24
- summaries = Flow::Summaries.new(flow_host.flows.find(params[:id]))
24
+ summaries = Flow::Summaries.new(hosted_flows.find_by_public_code!(params[:id]))
25
25
  summaries.describe(details[:summary]) unless details[:summary].nil?
26
26
  summaries.start_on(owned_pages.find_by(id: details[:intro_page_id])) unless details[:intro_page_id].nil?
27
27
  summaries.finish_on(owned_pages.find_by(id: details[:summary_page_id])) unless details[:summary_page_id].nil?
@@ -29,6 +29,7 @@ module Alembic
29
29
  def finished(answers, finished_run)
30
30
  @outputs = outputs_of(answers.transform_keys(&:to_s))
31
31
  Flow::Summaries.new(flow).pin(finished_run) if finished_run && run.nil?
32
+ Flow::Summaries.new(finished_run.flow).keep(finished_run, answers.transform_keys(&:to_s)) if finished_run
32
33
  @summary_page = Flow::Summaries.new(run&.flow || flow).summary_page
33
34
  render template: @summary_page&.live_version ? "alembic/flows/summary_page" : "alembic/flows/complete"
34
35
  end
@@ -81,6 +81,17 @@ module Alembic
81
81
  RunSummary.find_by(run: run)&.summary_version
82
82
  end
83
83
 
84
+ def keep(run, state)
85
+ pinned = RunSummary.find_by(run: run)
86
+ return if pinned.nil? || pinned.score || pinned.seconds_taken
87
+
88
+ pinned.update!(score: score_of(run, state), seconds_taken: seconds_taken_by(run))
89
+ end
90
+
91
+ def ranked
92
+ RunSummary.where(summary_version: versions).where.not(score: nil).order(score: :desc).order(RunSummary.arel_table[:seconds_taken].asc.nulls_last)
93
+ end
94
+
84
95
  def of_run(run, state)
85
96
  pinned = pinned_to(run)&.summary
86
97
  return [] if pinned.blank?
@@ -90,6 +101,17 @@ module Alembic
90
101
 
91
102
  private
92
103
 
104
+ def score_of(run, state)
105
+ of_run(run, state).find { |result| result.type == "weighted_sum" }&.value
106
+ end
107
+
108
+ def seconds_taken_by(run)
109
+ return unless run.flow.each_step?
110
+
111
+ last_answered = run.completed_at.values.max
112
+ (last_answered - run.created_at).to_i if last_answered
113
+ end
114
+
93
115
  def versions
94
116
  SummaryVersion.where(flow: @flow)
95
117
  end
@@ -9,6 +9,7 @@ class MoveFlowsOntoEasyFlow < ActiveRecord::Migration[8.1]
9
9
 
10
10
  class Definition < ActiveRecord::Base
11
11
  self.table_name = "easy_flow_definitions"
12
+ has_public_code
12
13
  end
13
14
 
14
15
  class OldVersion < ActiveRecord::Base
@@ -17,6 +18,7 @@ class MoveFlowsOntoEasyFlow < ActiveRecord::Migration[8.1]
17
18
 
18
19
  class Version < ActiveRecord::Base
19
20
  self.table_name = "easy_flow_versions"
21
+ has_public_code
20
22
  end
21
23
 
22
24
  class OldRun < ActiveRecord::Base
@@ -25,6 +27,7 @@ class MoveFlowsOntoEasyFlow < ActiveRecord::Migration[8.1]
25
27
 
26
28
  class Run < ActiveRecord::Base
27
29
  self.table_name = "easy_flow_runs"
30
+ has_public_code
28
31
  end
29
32
 
30
33
  class SummaryVersion < ActiveRecord::Base
@@ -0,0 +1,6 @@
1
+ class AddKeptResultToAlembicFlowRunSummaries < ActiveRecord::Migration[8.1]
2
+ def change
3
+ add_column :alembic_flow_run_summaries, :score, :integer
4
+ add_column :alembic_flow_run_summaries, :seconds_taken, :integer
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Alembic
2
- VERSION = "0.5.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alembic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.8'
60
+ version: '0.24'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.8'
67
+ version: '0.24'
68
68
  description: Alembic builds and runs data-driven interactive diagnostics — scored
69
69
  assessments and branching guides — that place a visitor on an outcome and capture
70
70
  the result. A runtime engine plus a UI builder.
@@ -211,6 +211,7 @@ files:
211
211
  - db/migrate/20260930233000_add_asks_on_one_page_to_alembic_flow_definition_summaries.rb
212
212
  - db/migrate/20261001120002_add_intro_page_to_alembic_flow_definition_summaries.rb
213
213
  - db/migrate/20261001170001_add_owner_to_alembic_pages.rb
214
+ - db/migrate/20261020120000_add_kept_result_to_alembic_flow_run_summaries.rb
214
215
  - lib/alembic.rb
215
216
  - lib/alembic/engine.rb
216
217
  - lib/alembic/leftover_stylesheet.rb