mirror of
				https://github.com/fspc/bike-database.git
				synced 2025-10-31 00:35:35 -04:00 
			
		
		
		
	lk | adds report for bikes fixed per week and some notes
This commit is contained in:
		
							parent
							
								
									87577ab14e
								
							
						
					
					
						commit
						daa4b912e6
					
				| @ -5,4 +5,7 @@ class ReportsController < ApplicationController | ||||
|     @yearly_data = Report.yearly_data | ||||
|   end | ||||
| 
 | ||||
|   def bikes_fixed_per_week | ||||
|     @weekly_data = Report.bikes_fixed_per_week | ||||
|   end | ||||
| end | ||||
|  | ||||
| @ -2,6 +2,13 @@ class Report | ||||
| 
 | ||||
|   @@years = Bike.all.each.map{|bike| bike.date_sold.year if bike.date_sold} | ||||
| 
 | ||||
|   def self.bikes_fixed_per_week | ||||
|     beginning_of_year = Time.now.beginning_of_year | ||||
|     bikes = Bike.where("entry_date > ?", beginning_of_year) | ||||
|     weekly_data = bikes.group_by{|b| DateTime.strptime(b.entry_date, "%m/%d/%y").beginning_of_week} | ||||
|     weekly_data.to_a.sort!{|a, b| a.first <=> b.first}.to_h | ||||
|   end | ||||
| 
 | ||||
|   def self.bikes_sold_per_year | ||||
|     counts = Hash.new(0) | ||||
|     @@years.each { |year| counts[year] += 1 } | ||||
| @ -13,7 +20,6 @@ class Report | ||||
|     years_prices = @@years.each_with_index.map{|year, index| {prices[index].to_s.to_sym => year}} | ||||
|     merged_years_prices = years_prices.reduce({}, :merge) | ||||
|     years_prices_grouped = merged_years_prices.group_by{|k, v| v} | ||||
|      | ||||
|     average_price_array = years_prices_grouped.each.map{ |k, year_values| | ||||
|       year_prices = year_values.each.map{|pair| pair[0]} | ||||
|       float_prices = year_prices.map{|price| price.to_s.to_f} | ||||
|  | ||||
							
								
								
									
										15
									
								
								app/views/reports/bikes_fixed_per_week.html.haml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/views/reports/bikes_fixed_per_week.html.haml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| .container | ||||
|   %h1 Bikes Fixed Per Week This Year | ||||
|   %p Because of some discrepancies in the way date data has been stored, this data may be off. Consider this feature *experimental* while this message persists. Contact Louis for more information. | ||||
|   %table.table | ||||
|     %thead | ||||
|       %tr | ||||
|         %th Week beginning | ||||
|         %th Number of Bikes | ||||
|         %th Mechanics Responsible | ||||
|     %tbody | ||||
|       - @weekly_data.each do |week, bikes| | ||||
|         %tr | ||||
|           %td= week.strftime("%m/%d/%y") | ||||
|           %td= bikes.length | ||||
|           %td= bikes.map(&:mechanic).uniq.to_sentence | ||||
| @ -20,10 +20,10 @@ Bikedb::Application.routes.draw do | ||||
|     get 'receipt' => 'freecyclery#receipt' | ||||
|     get 'print_select' => 'clients#print_select', on: :collection | ||||
|     get 'print_receipts' => 'clients#print_receipts', on: :collection | ||||
| 
 | ||||
|   end | ||||
| 
 | ||||
|   get 'closed_applications' => 'freecyclery#closed_applications' | ||||
|   get 'available_bikes' => 'freecyclery#available_bikes' | ||||
|   get 'bikes_sold_per_year' => 'reports#bikes_sold_per_year' | ||||
|   get 'bikes_fixed_per_week' => 'reports#bikes_fixed_per_week' | ||||
| end | ||||
|  | ||||
							
								
								
									
										17
									
								
								notes.txt
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								notes.txt
									
									
									
									
									
								
							| @ -1,5 +1,21 @@ | ||||
| change agency#phone_number to agency#phone | ||||
| 
 | ||||
| store date fixed as a real date instead of a string and fix all the data | ||||
|   null values should be date_created | ||||
|   empty strings should be date created | ||||
|   strings of format mm/dd/yy | ||||
|   strings of format mm/dd/yyyy | ||||
| 
 | ||||
| add mechanics table and change text input to a dropdown | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| when client is created without date, app breaks | ||||
| 
 | ||||
| on website, tailwind for tools initiative looks weird in carousel | ||||
| on mobile | ||||
| 
 | ||||
| @ -37,5 +53,4 @@ add recyclery logos & bike memorabilia pics all over app | ||||
| do bike sales labels fit into sleeves? (sheaths are 5x3.75) | ||||
| freecyclery bikes need receipts | ||||
| when application is voided, bike should go back to pool of bikes | ||||
| when client is created without date, app breaks | ||||
| phone calls made is unnecessary - notes are usualy used | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user