mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
fix: internal server error because of date parsing
This commit is contained in:
@@ -141,7 +141,7 @@ func (r *ExpenseRepositoryImpl) GetProgressRows(ctx context.Context, startDate,
|
||||
'Expenses' AS module,
|
||||
COALESCE(pf.flock_name, loc.name, fallback_loc.name, 'Unknown Farm') AS farm_name,
|
||||
COALESCE(k.name, `+unassignedSQL+`, 'Unknown Kandang') AS kandang_name,
|
||||
DATE(e.transaction_date) AS activity_date,
|
||||
CAST(DATE(e.transaction_date) AS TEXT) AS activity_date,
|
||||
COUNT(*) AS count
|
||||
`).
|
||||
Joins("LEFT JOIN (SELECT DISTINCT expense_id, project_flock_kandang_id, kandang_id FROM expense_nonstocks) en ON en.expense_id = e.id").
|
||||
@@ -179,7 +179,7 @@ func (r *ExpenseRepositoryImpl) GetProgressRows(ctx context.Context, startDate,
|
||||
|
||||
rows := make([]exportprogress.Row, 0, len(scanned))
|
||||
for _, item := range scanned {
|
||||
activityDate, err := time.Parse("2006-01-02", item.ActivityDate)
|
||||
activityDate, err := exportprogress.ParseActivityDate(item.ActivityDate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (r *MarketingRepositoryImpl) GetProgressRows(ctx context.Context, startDate
|
||||
'Marketings' AS module,
|
||||
COALESCE(pf.flock_name, loc.name, 'Unknown Farm') AS farm_name,
|
||||
COALESCE(k.name, `+unassignedSQL+`, 'Unknown Kandang') AS kandang_name,
|
||||
DATE(m.so_date) AS activity_date
|
||||
CAST(DATE(m.so_date) AS TEXT) AS activity_date
|
||||
`).
|
||||
Joins("JOIN marketing_products mp ON mp.marketing_id = m.id").
|
||||
Joins("JOIN product_warehouses pw ON pw.id = mp.product_warehouse_id").
|
||||
@@ -108,7 +108,7 @@ func (r *MarketingRepositoryImpl) GetProgressRows(ctx context.Context, startDate
|
||||
|
||||
rows := make([]exportprogress.Row, 0, len(scanned))
|
||||
for _, item := range scanned {
|
||||
activityDate, err := time.Parse("2006-01-02", item.ActivityDate)
|
||||
activityDate, err := exportprogress.ParseActivityDate(item.ActivityDate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ func (r *RecordingRepositoryImpl) GetProgressRows(ctx context.Context, startDate
|
||||
'Recordings' AS module,
|
||||
COALESCE(pf.flock_name, loc.name, 'Unknown Farm') AS farm_name,
|
||||
COALESCE(k.name, `+unassignedSQL+`, 'Unknown Kandang') AS kandang_name,
|
||||
DATE(r.record_datetime) AS activity_date,
|
||||
CAST(DATE(r.record_datetime) AS TEXT) AS activity_date,
|
||||
COUNT(*) AS count
|
||||
`).
|
||||
Joins("JOIN project_flock_kandangs pfk ON pfk.id = r.project_flock_kandangs_id").
|
||||
@@ -296,7 +296,7 @@ func (r *RecordingRepositoryImpl) GetProgressRows(ctx context.Context, startDate
|
||||
|
||||
rows := make([]exportprogress.Row, 0, len(scanned))
|
||||
for _, item := range scanned {
|
||||
activityDate, err := time.Parse("2006-01-02", item.ActivityDate)
|
||||
activityDate, err := exportprogress.ParseActivityDate(item.ActivityDate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ func (r *PurchaseRepositoryImpl) GetProgressRows(ctx context.Context, startDate,
|
||||
'Purchases' AS module,
|
||||
COALESCE(pf_explicit.flock_name, pf_active.flock_name, kandang_loc.name, warehouse_loc.name, 'Unknown Farm') AS farm_name,
|
||||
COALESCE(k_explicit.name, k_active.name, wk.name, `+unassignedSQL+`, 'Unknown Kandang') AS kandang_name,
|
||||
DATE(p.po_date) AS activity_date
|
||||
CAST(DATE(p.po_date) AS TEXT) AS activity_date
|
||||
`).
|
||||
Joins("JOIN purchase_items pi ON pi.purchase_id = p.id").
|
||||
Joins("JOIN warehouses w ON w.id = pi.warehouse_id").
|
||||
@@ -340,7 +340,7 @@ func (r *PurchaseRepositoryImpl) GetProgressRows(ctx context.Context, startDate,
|
||||
|
||||
rows := make([]exportprogress.Row, 0, len(scanned))
|
||||
for _, item := range scanned {
|
||||
activityDate, err := time.Parse("2006-01-02", item.ActivityDate)
|
||||
activityDate, err := exportprogress.ParseActivityDate(item.ActivityDate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user