mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Repository Structure:
- Move files from cluttered root directory into organized structure
- Create archive/ for archived data and scraper results
- Create bugulma/ for the complete application (frontend + backend)
- Create data/ for sample datasets and reference materials
- Create docs/ for comprehensive documentation structure
- Create scripts/ for utility scripts and API tools
Backend Implementation:
- Implement 3 missing backend endpoints identified in gap analysis:
* GET /api/v1/organizations/{id}/matching/direct - Direct symbiosis matches
* GET /api/v1/users/me/organizations - User organizations
* POST /api/v1/proposals/{id}/status - Update proposal status
- Add complete proposal domain model, repository, and service layers
- Create database migration for proposals table
- Fix CLI server command registration issue
API Documentation:
- Add comprehensive proposals.md API documentation
- Update README.md with Users and Proposals API sections
- Document all request/response formats, error codes, and business rules
Code Quality:
- Follow existing Go backend architecture patterns
- Add proper error handling and validation
- Match frontend expected response schemas
- Maintain clean separation of concerns (handler -> service -> repository)
73 lines
1.9 KiB
Go
73 lines
1.9 KiB
Go
package testutils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
|
|
"bugulma/backend/internal/domain"
|
|
)
|
|
|
|
// NewSampleResourceFlow creates a sample resource flow for testing
|
|
func NewSampleResourceFlow() *domain.ResourceFlow {
|
|
temp := 100.0
|
|
purity := 95.0
|
|
quality := domain.Quality{
|
|
TemperatureCelsius: &temp,
|
|
PurityPct: &purity,
|
|
}
|
|
qualityJSON, _ := json.Marshal(quality)
|
|
|
|
quantity := domain.Quantity{
|
|
Amount: 1000,
|
|
Unit: "kWh",
|
|
TemporalUnit: "hour",
|
|
Variability: 0.1,
|
|
}
|
|
quantityJSON, _ := json.Marshal(quantity)
|
|
|
|
timeProfile := domain.TimeProfile{
|
|
Availability: map[string]domain.TimeRange{
|
|
"monday": {Start: "09:00", End: "17:00"},
|
|
"tuesday": {Start: "09:00", End: "17:00"},
|
|
"wednesday": {Start: "09:00", End: "17:00"},
|
|
"thursday": {Start: "09:00", End: "17:00"},
|
|
"friday": {Start: "09:00", End: "17:00"},
|
|
"saturday": {Start: "09:00", End: "17:00"},
|
|
"sunday": {Start: "09:00", End: "17:00"},
|
|
},
|
|
SupplyPattern: "continuous",
|
|
}
|
|
timeProfileJSON, _ := json.Marshal(timeProfile)
|
|
|
|
economicData := domain.EconomicData{
|
|
CostOut: 0.1,
|
|
TransportationCost: 0.05,
|
|
}
|
|
economicDataJSON, _ := json.Marshal(economicData)
|
|
|
|
constraints := domain.Constraints{
|
|
MaxDistanceKm: 50,
|
|
}
|
|
constraintsJSON, _ := json.Marshal(constraints)
|
|
|
|
return &domain.ResourceFlow{
|
|
ID: "rf-1",
|
|
OrganizationID: "org-1",
|
|
SiteID: "site-1",
|
|
Direction: domain.DirectionOutput,
|
|
Type: domain.TypeHeat,
|
|
Quality: datatypes.JSON(qualityJSON),
|
|
Quantity: datatypes.JSON(quantityJSON),
|
|
TimeProfile: datatypes.JSON(timeProfileJSON),
|
|
EconomicData: datatypes.JSON(economicDataJSON),
|
|
Constraints: datatypes.JSON(constraintsJSON),
|
|
PrecisionLevel: domain.PrecisionMeasured,
|
|
SourceType: domain.SourceDevice,
|
|
DeviceSignature: "device-123",
|
|
CreatedAt: time.Now().Add(-24 * time.Hour),
|
|
UpdatedAt: time.Now(),
|
|
}
|
|
}
|