-
-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 4773-reset-password-and-invitation-expiry
- Loading branch information
Showing
39 changed files
with
791 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# to be called from Clock | ||
module BackupDbRds | ||
def self.run | ||
logger = Logger.new($stdout) | ||
logger.info("Performing dump of the database.") | ||
|
||
current_time = Time.current.strftime("%Y%m%d%H%M%S") | ||
|
||
logger.info("Copying the database...") | ||
backup_filename = "#{current_time}.rds.dump" | ||
system("PGPASSWORD='#{ENV["DIAPER_DB_PASSWORD"]}' pg_dump -Fc -v --host=#{ENV["DIAPER_DB_HOST"]} --username=#{ENV["DIAPER_DB_USERNAME"]} --dbname=#{ENV["DIAPER_DB_DATABASE"]} -f #{backup_filename}") | ||
|
||
account_name = ENV["AZURE_STORAGE_ACCOUNT_NAME"] | ||
account_key = ENV["AZURE_STORAGE_ACCESS_KEY"] | ||
|
||
blob_client = Azure::Storage::Blob::BlobService.create( | ||
storage_account_name: account_name, | ||
storage_access_key: account_key | ||
) | ||
|
||
logger.info("Uploading #{backup_filename}") | ||
blob_client.create_block_blob("backups", backup_filename, File.read(backup_filename)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,24 @@ | ||
class RequestsTotalItemsService | ||
def initialize(requests:) | ||
@requests = requests | ||
@requests = requests.includes(item_requests: {item: :request_units}) | ||
end | ||
|
||
def calculate | ||
return unless requests | ||
|
||
request_items_array = [] | ||
|
||
request_items.each do |items| | ||
items.each do |json| | ||
request_items_array << [item_name(json['item_id']), json['quantity']] | ||
end | ||
totals = Hash.new(0) | ||
item_requests.each do |item_request| | ||
totals[item_request.name_with_unit] += item_request.quantity.to_i | ||
end | ||
|
||
request_items_array.inject({}) do |item, (quantity, total)| | ||
item[quantity] ||= 0 | ||
item[quantity] += total.to_i | ||
item | ||
end | ||
totals | ||
end | ||
|
||
private | ||
|
||
attr_accessor :requests | ||
|
||
def request_items | ||
@request_items ||= requests.pluck(:request_items) | ||
end | ||
|
||
def request_items_ids | ||
request_items.flat_map { |jitem| jitem.map { |item| item["item_id"] } } | ||
end | ||
|
||
def items_names | ||
@items_names ||= Item.where(id: request_items_ids).as_json(only: [:id, :name]) | ||
end | ||
|
||
def item_name(id) | ||
item_found = items_names.find { |item| item["id"] == id } | ||
item_found&.fetch('name') || '*Unknown Item*' | ||
def item_requests | ||
@item_requests ||= requests.flat_map(&:item_requests) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ | |
</section> | ||
|
||
<%= render 'form' %> | ||
<%= render partial: "barcode_items/barcode_modal" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Hi <%= @partner.name %> | ||
|
||
<%= @organization.name %> has approved your application. | ||
You have been approved to make requests for essentials to <%= @organization.name %>. | ||
|
||
Check out your dashboard: <%= partners_dashboard_url %> |
Oops, something went wrong.