Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rromanchuk committed Apr 10, 2024
1 parent 5cf3650 commit c56626f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
18 changes: 18 additions & 0 deletions personal/app/models/tds/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ def pending?
processed_at.nil? && failed_at.nil?
end

def self.pending_count
Rails.cache.fetch("batch-pending-count", expires_in: 1.hour) do
Tds::Batch.pending.count
end
end

def self.complete_count
Rails.cache.fetch("batch-complete-count", expires_in: 6.hours) do
Tds::Batch.complete.count
end
end

def self.failed_count
Rails.cache.fetch("batch-failed-count", expires_in: 1.hour) do
Tds::Batch.failed.count
end
end

def process_batch!
return if processed_at.present?

Expand Down
4 changes: 2 additions & 2 deletions personal/app/views/tds/batches/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<div class="card" style="width: 10rem;">
<div class="card-body text-center">
<p class="card-title">Pending batches</p>
<p class="card-text h5 text-warning"><%= number_with_delimiter(Tds::Batch.pending.count) %></p>
<p class="card-text h5 text-warning"><%= number_with_delimiter(Tds::Batch.pending_count) %></p>
</div>
</div>
</div>
<div class="col">
<div class="card" style="width: 10rem;">
<div class="card-body text-center">
<p class="card-title">Completed</p>
<p class="card-text h5 text-success"><%= number_with_delimiter(Tds::Batch.complete.count) %></p>
<p class="card-text h5 text-success"><%= number_with_delimiter(Tds::Batch.complete_count) %></p>
</div>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions personal/db/wx/20240410023029_add_indexes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddIndexes < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
def change
add_index :tds_batches, :created_at, algorithm: :concurrently
add_index :tds_batches, :failed_at, algorithm: :concurrently
end
end
17 changes: 17 additions & 0 deletions personal/db/wx_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ DROP INDEX IF EXISTS public.index_tds_metars_on_observation_time;
DROP INDEX IF EXISTS public.index_tds_metars_on_batch_id;
DROP INDEX IF EXISTS public.index_tds_batches_on_report_type;
DROP INDEX IF EXISTS public.index_tds_batches_on_processed_at;
DROP INDEX IF EXISTS public.index_tds_batches_on_failed_at;
DROP INDEX IF EXISTS public.index_tds_batches_on_created_at;
DROP INDEX IF EXISTS public.index_tds_aireps_uniqueness;
DROP INDEX IF EXISTS public.index_tds_aireps_on_observation_time;
DROP INDEX IF EXISTS public.index_tds_aireps_on_batch_id;
Expand Down Expand Up @@ -454,6 +456,20 @@ CREATE INDEX index_tds_aireps_on_observation_time ON public.tds_aireps USING btr
CREATE UNIQUE INDEX index_tds_aireps_uniqueness ON public.tds_aireps USING btree (raw_text, observation_time);


--
-- Name: index_tds_batches_on_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_tds_batches_on_created_at ON public.tds_batches USING btree (created_at);


--
-- Name: index_tds_batches_on_failed_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_tds_batches_on_failed_at ON public.tds_batches USING btree (failed_at);


--
-- Name: index_tds_batches_on_processed_at; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -658,6 +674,7 @@ ALTER TABLE ONLY public.tds_tafs
SET search_path TO "$user", public;

INSERT INTO "schema_migrations" (version) VALUES
('20240410023029'),
('20240102002232'),
('20231231175136'),
('20231231074449'),
Expand Down

0 comments on commit c56626f

Please sign in to comment.