alembic 0.6.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: 22fc670649f7009174b0a84e4e4e1955a621067d57854f2e40ab53a03da936f2
4
- data.tar.gz: 88491c8e1d8a05a1697815fdbd86a4b75a5f668c1ba6c69a28a2c7422c8fdb74
3
+ metadata.gz: e81efddf247765d5a20f6134dc45c4f3d66199cf3e66c9247266614b7bce598a
4
+ data.tar.gz: 60fb3ffd6451a586ef2e575006821e3fc92fcdbeb15d4295958c449db38beebc
5
5
  SHA512:
6
- metadata.gz: 51e80d156b5b4d17ca07f5deda996b49f75433fe1914d764afd4dfab6391af7b89cac91dbf619e5642c664a1f0f76ca116a0c5d6eff712b63974ccfd21672e78
7
- data.tar.gz: 3f83888a0602046971637c593a6950586bd29fc1075aa66d0eb6485197101c23215a197281e8dde0680483cdee9086a92bb9344d8f1ebdab4ab734f1e7dd9146
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_by_public_code!(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
@@ -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.6.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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -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