diff --git a/api/v1/handlers/atmosphere.go b/api/v1/handlers/atmosphere.go index 6de70d5..7b7662d 100644 --- a/api/v1/handlers/atmosphere.go +++ b/api/v1/handlers/atmosphere.go @@ -51,8 +51,8 @@ import ( // } // Helper function to get the day of the week from a timestamp -func getDayOfWeek(timestamp int64) int32 { - return int32(time.Unix(timestamp, 0).Weekday()) +func getDayOfWeek(timestamp int64) int64 { + return int64(time.Unix(timestamp, 0).Weekday()) } /* Example response: @@ -151,13 +151,13 @@ func WeatherForecastHandler(c *gin.Context) { Description: condition["description"].(string), }, Temperature: &models.Temperature{ - Current: float32(temperature["temp"].(float64)), - Min: float32(temperature["temp_min"].(float64)), - Max: float32(temperature["temp_max"].(float64)), + Current: temperature["temp"].(float64), + Min: temperature["temp_min"].(float64), + Max: temperature["temp_max"].(float64), }, Sunrise: sunrise, Sunset: sunset, - DayOfWeek: getDayOfWeek(int64(forecastMap["dt"].(float64))), + DayOfWeek: getDayOfWeek(forecastMap["dt"].(int64)), }) } @@ -220,9 +220,9 @@ func CurrentWeatherHandler(c *gin.Context) { Description: condition["description"].(string), }, Temperature: &models.Temperature{ - Current: float32(temperature["temp"].(float64)), - Min: float32(temperature["temp_min"].(float64)), - Max: float32(temperature["temp_max"].(float64)), + Current: temperature["temp"].(float64), + Min: temperature["temp_min"].(float64), + Max: temperature["temp_max"].(float64), }, Sunrise: sunrise, Sunset: sunset, @@ -275,15 +275,15 @@ func CurrentAirPollutionHandler(c *gin.Context) { components := openWeatherData["list"].([]interface{})[0].(map[string]interface{})["components"].(map[string]interface{}) airPollutionResponse := &models.AirPollutionResponse{ - Components: map[string]float32{ - "co": float32(components["co"].(float64)), - "no": float32(components["no"].(float64)), - "no2": float32(components["no2"].(float64)), - "o3": float32(components["o3"].(float64)), - "so2": float32(components["so2"].(float64)), - "pm2_5": float32(components["pm2_5"].(float64)), - "pm10": float32(components["pm10"].(float64)), - "nh3": float32(components["nh3"].(float64)), + Components: map[string]float64{ + "co": components["co"].(float64), + "no": components["no"].(float64), + "no2": components["no2"].(float64), + "o3": components["o3"].(float64), + "so2": components["so2"].(float64), + "pm2_5": components["pm2_5"].(float64), + "pm10": components["pm10"].(float64), + "nh3": components["nh3"].(float64), }, } diff --git a/api/v1/handlers/schedule.go b/api/v1/handlers/schedule.go index 7c702c9..dc4c35d 100644 --- a/api/v1/handlers/schedule.go +++ b/api/v1/handlers/schedule.go @@ -21,7 +21,7 @@ func GetDivisionHandler(c *gin.Context) { return } - division, err := datastore.GetDivision(uint32(index)) + division, err := datastore.GetDivision(uint64(index)) if err != nil { if division == nil { c.JSON(http.StatusNotFound, gin.H{ @@ -53,7 +53,7 @@ func GetTeacherHandler(c *gin.Context) { return } - teacher, err := datastore.GetTeacher(uint32(index)) + teacher, err := datastore.GetTeacher(uint64(index)) if err != nil { if teacher == nil { c.JSON(http.StatusNotFound, gin.H{ @@ -84,7 +84,7 @@ func GetRoomHandler(c *gin.Context) { return } - room, err := datastore.GetRoom(uint32(index)) + room, err := datastore.GetRoom(uint64(index)) if err != nil { if room == nil { c.JSON(http.StatusNotFound, gin.H{ diff --git a/common/models/data.pb.go b/common/models/data.pb.go index 400343d..bfdbd48 100644 --- a/common/models/data.pb.go +++ b/common/models/data.pb.go @@ -27,7 +27,7 @@ type DivisionsDesignators struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Divisions map[string]uint32 `protobuf:"bytes,1,rep,name=divisions,proto3" json:"divisions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + Divisions map[string]uint64 `protobuf:"bytes,1,rep,name=divisions,proto3" json:"divisions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } func (x *DivisionsDesignators) Reset() { @@ -60,7 +60,7 @@ func (*DivisionsDesignators) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{0} } -func (x *DivisionsDesignators) GetDivisions() map[string]uint32 { +func (x *DivisionsDesignators) GetDivisions() map[string]uint64 { if x != nil { return x.Divisions } @@ -72,7 +72,7 @@ type TeachersDesignators struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Teachers map[string]uint32 `protobuf:"bytes,1,rep,name=teachers,proto3" json:"teachers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + Teachers map[string]uint64 `protobuf:"bytes,1,rep,name=teachers,proto3" json:"teachers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } func (x *TeachersDesignators) Reset() { @@ -105,7 +105,7 @@ func (*TeachersDesignators) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{1} } -func (x *TeachersDesignators) GetTeachers() map[string]uint32 { +func (x *TeachersDesignators) GetTeachers() map[string]uint64 { if x != nil { return x.Teachers } @@ -117,7 +117,7 @@ type RoomsDesignators struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Rooms map[string]uint32 `protobuf:"bytes,1,rep,name=rooms,proto3" json:"rooms,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + Rooms map[string]uint64 `protobuf:"bytes,1,rep,name=rooms,proto3" json:"rooms,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } func (x *RoomsDesignators) Reset() { @@ -150,7 +150,7 @@ func (*RoomsDesignators) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{2} } -func (x *RoomsDesignators) GetRooms() map[string]uint32 { +func (x *RoomsDesignators) GetRooms() map[string]uint64 { if x != nil { return x.Rooms } @@ -215,9 +215,9 @@ type Temperature struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Current float32 `protobuf:"fixed32,1,opt,name=current,proto3" json:"current,omitempty"` - Min float32 `protobuf:"fixed32,2,opt,name=min,proto3" json:"min,omitempty"` - Max float32 `protobuf:"fixed32,3,opt,name=max,proto3" json:"max,omitempty"` + Current float64 `protobuf:"fixed64,1,opt,name=current,proto3" json:"current,omitempty"` + Min float64 `protobuf:"fixed64,2,opt,name=min,proto3" json:"min,omitempty"` + Max float64 `protobuf:"fixed64,3,opt,name=max,proto3" json:"max,omitempty"` } func (x *Temperature) Reset() { @@ -250,21 +250,21 @@ func (*Temperature) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{4} } -func (x *Temperature) GetCurrent() float32 { +func (x *Temperature) GetCurrent() float64 { if x != nil { return x.Current } return 0 } -func (x *Temperature) GetMin() float32 { +func (x *Temperature) GetMin() float64 { if x != nil { return x.Min } return 0 } -func (x *Temperature) GetMax() float32 { +func (x *Temperature) GetMax() float64 { if x != nil { return x.Max } @@ -280,7 +280,7 @@ type Forecast struct { Temperature *Temperature `protobuf:"bytes,2,opt,name=temperature,proto3" json:"temperature,omitempty"` Sunrise int64 `protobuf:"varint,3,opt,name=sunrise,proto3" json:"sunrise,omitempty"` Sunset int64 `protobuf:"varint,4,opt,name=sunset,proto3" json:"sunset,omitempty"` - DayOfWeek int32 `protobuf:"varint,5,opt,name=dayOfWeek,proto3" json:"dayOfWeek,omitempty"` + DayOfWeek int64 `protobuf:"varint,5,opt,name=dayOfWeek,proto3" json:"dayOfWeek,omitempty"` } func (x *Forecast) Reset() { @@ -341,7 +341,7 @@ func (x *Forecast) GetSunset() int64 { return 0 } -func (x *Forecast) GetDayOfWeek() int32 { +func (x *Forecast) GetDayOfWeek() int64 { if x != nil { return x.DayOfWeek } @@ -483,7 +483,7 @@ type AirPollutionResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Components map[string]float32 `protobuf:"bytes,1,rep,name=components,proto3" json:"components,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed32,2,opt,name=value,proto3"` + Components map[string]float64 `protobuf:"bytes,1,rep,name=components,proto3" json:"components,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed64,2,opt,name=value,proto3"` } func (x *AirPollutionResponse) Reset() { @@ -516,7 +516,7 @@ func (*AirPollutionResponse) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{8} } -func (x *AirPollutionResponse) GetComponents() map[string]float32 { +func (x *AirPollutionResponse) GetComponents() map[string]float64 { if x != nil { return x.Components } @@ -528,8 +528,8 @@ type Timestamp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Hour int32 `protobuf:"varint,1,opt,name=hour,proto3" json:"hour,omitempty"` - Minute int32 `protobuf:"varint,2,opt,name=minute,proto3" json:"minute,omitempty"` + Hour int64 `protobuf:"varint,1,opt,name=hour,proto3" json:"hour,omitempty"` + Minute int64 `protobuf:"varint,2,opt,name=minute,proto3" json:"minute,omitempty"` } func (x *Timestamp) Reset() { @@ -562,14 +562,14 @@ func (*Timestamp) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{9} } -func (x *Timestamp) GetHour() int32 { +func (x *Timestamp) GetHour() int64 { if x != nil { return x.Hour } return 0 } -func (x *Timestamp) GetMinute() int32 { +func (x *Timestamp) GetMinute() int64 { if x != nil { return x.Minute } @@ -846,7 +846,7 @@ type Teacher struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Index uint32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` Designator string `protobuf:"bytes,2,opt,name=designator,proto3" json:"designator,omitempty"` FullName string `protobuf:"bytes,3,opt,name=full_name,json=fullName,proto3" json:"full_name,omitempty"` Schedule *Schedule `protobuf:"bytes,4,opt,name=schedule,proto3" json:"schedule,omitempty"` @@ -882,7 +882,7 @@ func (*Teacher) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{15} } -func (x *Teacher) GetIndex() uint32 { +func (x *Teacher) GetIndex() uint64 { if x != nil { return x.Index } @@ -915,7 +915,7 @@ type Room struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Index uint32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` Designator string `protobuf:"bytes,2,opt,name=designator,proto3" json:"designator,omitempty"` Schedule *Schedule `protobuf:"bytes,3,opt,name=schedule,proto3" json:"schedule,omitempty"` } @@ -950,7 +950,7 @@ func (*Room) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{16} } -func (x *Room) GetIndex() uint32 { +func (x *Room) GetIndex() uint64 { if x != nil { return x.Index } @@ -976,7 +976,7 @@ type Division struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Index uint32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` Designator string `protobuf:"bytes,2,opt,name=designator,proto3" json:"designator,omitempty"` FullName string `protobuf:"bytes,3,opt,name=full_name,json=fullName,proto3" json:"full_name,omitempty"` Schedule *Schedule `protobuf:"bytes,4,opt,name=schedule,proto3" json:"schedule,omitempty"` @@ -1012,7 +1012,7 @@ func (*Division) Descriptor() ([]byte, []int) { return file_data_proto_rawDescGZIP(), []int{17} } -func (x *Division) GetIndex() uint32 { +func (x *Division) GetIndex() uint64 { if x != nil { return x.Index } @@ -1114,7 +1114,7 @@ var file_data_proto_rawDesc = []byte{ 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3c, 0x0a, 0x0e, 0x44, 0x69, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x97, 0x01, 0x0a, 0x13, 0x54, 0x65, 0x61, 0x63, 0x68, 0x65, 0x72, 0x73, 0x44, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x43, 0x0a, 0x08, 0x74, 0x65, 0x61, 0x63, 0x68, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x64, @@ -1124,7 +1124,7 @@ var file_data_proto_rawDesc = []byte{ 0x3b, 0x0a, 0x0d, 0x54, 0x65, 0x61, 0x63, 0x68, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x85, 0x01, 0x0a, + 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x85, 0x01, 0x0a, 0x10, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x44, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x37, 0x0a, 0x05, 0x72, 0x6f, 0x6f, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x44, 0x65, 0x73, @@ -1132,16 +1132,16 @@ var file_data_proto_rawDesc = []byte{ 0x74, 0x72, 0x79, 0x52, 0x05, 0x72, 0x6f, 0x6f, 0x6d, 0x73, 0x1a, 0x38, 0x0a, 0x0a, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x41, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x4b, 0x0a, 0x0b, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x03, 0x6d, - 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x61, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x6d, + 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x61, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x6d, 0x61, 0x78, 0x22, 0xbe, 0x01, 0x0a, 0x08, 0x46, 0x6f, 0x72, 0x65, 0x63, 0x61, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6e, 0x64, @@ -1153,7 +1153,7 @@ var file_data_proto_rawDesc = []byte{ 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x73, 0x75, 0x6e, 0x72, 0x69, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, 0x6e, 0x73, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x75, 0x6e, 0x73, 0x65, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x61, 0x79, 0x4f, 0x66, - 0x57, 0x65, 0x65, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x64, 0x61, 0x79, 0x4f, + 0x57, 0x65, 0x65, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x64, 0x61, 0x79, 0x4f, 0x66, 0x57, 0x65, 0x65, 0x6b, 0x22, 0x52, 0x0a, 0x10, 0x46, 0x6f, 0x72, 0x65, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, @@ -1181,11 +1181,11 @@ var file_data_proto_rawDesc = []byte{ 0x6e, 0x74, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x37, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, - 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x75, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x68, + 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x75, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x68, 0x6f, 0x75, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x6d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x22, 0x55, 0x0a, 0x09, 0x54, + 0x01, 0x28, 0x03, 0x52, 0x06, 0x6d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x22, 0x55, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, @@ -1218,7 +1218,7 @@ var file_data_proto_rawDesc = []byte{ 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x44, 0x61, 0x79, 0x52, 0x0c, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x44, 0x61, 0x79, 0x73, 0x22, 0x88, 0x01, 0x0a, 0x07, 0x54, 0x65, 0x61, 0x63, 0x68, 0x65, - 0x72, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, + 0x72, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x75, 0x6c, 0x6c, 0x5f, @@ -1227,14 +1227,14 @@ var file_data_proto_rawDesc = []byte{ 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x68, 0x0a, 0x04, 0x52, 0x6f, 0x6f, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1e, + 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x2a, 0x0a, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x89, 0x01, 0x0a, 0x08, 0x44, 0x69, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1e, 0x0a, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x75, 0x6c, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, diff --git a/core/datastore/crud.go b/core/datastore/crud.go index b54f118..275611d 100644 --- a/core/datastore/crud.go +++ b/core/datastore/crud.go @@ -51,7 +51,7 @@ func SetDivision(division *models.Division) error { return setItem(key, division) } -func GetDivision(index uint32) (*models.Division, error) { +func GetDivision(index uint64) (*models.Division, error) { key := []byte(fmt.Sprintf("division:%d", index)) division := &models.Division{} err := getItem(key, division) @@ -61,7 +61,7 @@ func GetDivision(index uint32) (*models.Division, error) { return division, nil } -func DeleteDivision(index uint32) error { +func DeleteDivision(index uint64) error { key := []byte(fmt.Sprintf("division:%d", index)) return deleteItem(key) } @@ -71,7 +71,7 @@ func SetTeacher(teacher *models.Teacher) error { return setItem(key, teacher) } -func GetTeacher(index uint32) (*models.Teacher, error) { +func GetTeacher(index uint64) (*models.Teacher, error) { key := []byte(fmt.Sprintf("teacher:%d", index)) teacher := &models.Teacher{} err := getItem(key, teacher) @@ -81,7 +81,7 @@ func GetTeacher(index uint32) (*models.Teacher, error) { return teacher, nil } -func DeleteTeacher(index uint32) error { +func DeleteTeacher(index uint64) error { key := []byte(fmt.Sprintf("teacher:%d", index)) return deleteItem(key) } @@ -91,7 +91,7 @@ func SetRoom(room *models.Room) error { return setItem(key, room) } -func GetRoom(index uint32) (*models.Room, error) { +func GetRoom(index uint64) (*models.Room, error) { key := []byte(fmt.Sprintf("room:%d", index)) room := &models.Room{} err := getItem(key, room) @@ -101,7 +101,7 @@ func GetRoom(index uint32) (*models.Room, error) { return room, nil } -func DeleteRoom(index uint32) error { +func DeleteRoom(index uint64) error { key := []byte(fmt.Sprintf("room:%d", index)) return deleteItem(key) } \ No newline at end of file diff --git a/core/scraper/observers.go b/core/scraper/observers.go index 4053f39..2d5a301 100644 --- a/core/scraper/observers.go +++ b/core/scraper/observers.go @@ -14,10 +14,10 @@ import ( func ObserveDivisions() { fmt.Println("observing divisions") - newDivisionObserver := func(index uint32) *observer.Observer { - url := fmt.Sprintf(Config.BaseUrl+Config.Endpoints.Division, index) + newDivisionObserver := func(index uint64) *observer.Observer { + url := fmt.Sprintf(Config.BaseUrl + Config.Endpoints.Division, index) // So they don't all refresh at the same time - interval := time.Duration((index+1)/10+15) * time.Second + interval := time.Duration((index + 1) / 10 + 15) * time.Second return observer.NewObserver(url, interval, func(doc *goquery.Document) string { var content []string doc.Find("table.tabela").Each(func(i int, table *goquery.Selection) { @@ -36,7 +36,7 @@ func ObserveDivisions() { }) } - startDivisionObserver := func(observer *observer.Observer, index uint32) { + startDivisionObserver := func(observer *observer.Observer, index uint64) { observer.Start(func() { division, err := ScrapeDivision(index) if err != nil { @@ -52,7 +52,7 @@ func ObserveDivisions() { } refreshDivisionsObservers := func() { - existingIndexes := make(map[uint32]bool) + existingIndexes := make(map[uint64]bool) for _, index := range DivisionsIndexes { existingIndexes[index] = true if _, exists := DivisionsObservers[index]; !exists { @@ -110,7 +110,7 @@ func ObserveDivisions() { func ObserveTeachers() { fmt.Println("observing teachers") - newTeacherObserver := func(index uint32) *observer.Observer { + newTeacherObserver := func(index uint64) *observer.Observer { url := fmt.Sprintf(Config.BaseUrl+Config.Endpoints.Teacher, index) interval := time.Duration((index+1)/10+15) * time.Second return observer.NewObserver(url, interval, func(doc *goquery.Document) string { @@ -125,7 +125,7 @@ func ObserveTeachers() { }) } - startTeacherObserver := func(observer *observer.Observer, index uint32) { + startTeacherObserver := func(observer *observer.Observer, index uint64) { observer.Start(func() { teacher, err := ScrapeTeacher(index) if err != nil { @@ -141,7 +141,7 @@ func ObserveTeachers() { } refreshTeachersObservers := func() { - existingIndexes := make(map[uint32]bool) + existingIndexes := make(map[uint64]bool) for _, index := range TeachersIndexes { existingIndexes[index] = true if _, exists := TeachersObservers[index]; !exists { @@ -197,7 +197,7 @@ func ObserveTeachers() { func ObserveRooms() { fmt.Println("observing rooms") - newRoomObserver := func(index uint32) *observer.Observer { + newRoomObserver := func(index uint64) *observer.Observer { url := fmt.Sprintf(Config.BaseUrl + Config.Endpoints.Room, index) interval := time.Duration((index + 1) / 10 + 15) * time.Second return observer.NewObserver(url, interval, func(doc *goquery.Document) string { @@ -212,7 +212,7 @@ func ObserveRooms() { }) } - startRoomObserver := func(observer *observer.Observer, index uint32) { + startRoomObserver := func(observer *observer.Observer, index uint64) { observer.Start(func() { room, err := ScrapeRoom(index) if err != nil { @@ -228,7 +228,7 @@ func ObserveRooms() { } refreshRoomsObservers := func() { - existingIndexes := make(map[uint32]bool) + existingIndexes := make(map[uint64]bool) for _, index := range RoomsIndexes { existingIndexes[index] = true if _, exists := RoomsObservers[index]; !exists { diff --git a/core/scraper/scraper.go b/core/scraper/scraper.go index 743c269..1b84e9a 100644 --- a/core/scraper/scraper.go +++ b/core/scraper/scraper.go @@ -24,40 +24,40 @@ var ( ) var ( - DivisionsIndexes []uint32 - TeachersIndexes []uint32 - RoomsIndexes []uint32 + DivisionsIndexes []uint64 + TeachersIndexes []uint64 + RoomsIndexes []uint64 DivisionsListObserver *observer.Observer TeachersListObserver *observer.Observer RoomsListObserver *observer.Observer ) -var DivisionsObservers = make(map[uint32]*observer.Observer) -var TeachersObservers = make(map[uint32]*observer.Observer) -var RoomsObservers = make(map[uint32]*observer.Observer) +var DivisionsObservers = make(map[uint64]*observer.Observer) +var TeachersObservers = make(map[uint64]*observer.Observer) +var RoomsObservers = make(map[uint64]*observer.Observer) var DivisionsDesignators = &models.DivisionsDesignators{ - Divisions: make(map[string]uint32), + Divisions: make(map[string]uint64), } var TeachersDesignators = &models.TeachersDesignators{ - Teachers: make(map[string]uint32), + Teachers: make(map[string]uint64), } var RoomsDesignators = &models.RoomsDesignators{ - Rooms: make(map[string]uint32), + Rooms: make(map[string]uint64), } -func makeDivisionEndpoint(index uint32) string { +func makeDivisionEndpoint(index uint64) string { return fmt.Sprintf(Config.Endpoints.Division, index) } -func makeTeacherEndpoint(index uint32) string { +func makeTeacherEndpoint(index uint64) string { return fmt.Sprintf(Config.Endpoints.Teacher, index) } -func makeRoomEndpoint(index uint32) string { +func makeRoomEndpoint(index uint64) string { return fmt.Sprintf(Config.Endpoints.Room, index) } @@ -119,13 +119,13 @@ func parseTimeRange(s string) (models.TimeRange, error) { } start := models.Timestamp{ - Hour: int32(startHour), - Minute: int32(startMinute), + Hour: startHour, + Minute: startMinute, } end := models.Timestamp{ - Hour: int32(endHour), - Minute: int32(endMinute), + Hour: endHour, + Minute: endMinute, } return models.TimeRange{Start: &start, End: &end}, nil @@ -244,7 +244,6 @@ func scrapeSchedule(doc *goquery.Document) (*models.Schedule, error) { doc.Find("table.tabela > tbody > tr > td").Each(func(i int, rowElement *goquery.Selection) { if columnNumber >= columnsCount { - //fmt.Println() columnNumber = 1 } else { columnNumber++ @@ -291,7 +290,7 @@ func scrapeSchedule(doc *goquery.Document) (*models.Schedule, error) { return schedule, nil } -func ScrapeDivision(index uint32) (*models.Division, error) { +func ScrapeDivision(index uint64) (*models.Division, error) { endpoint := makeDivisionEndpoint(index) doc, err := utils.OpenDoc(Config.BaseUrl, endpoint) if err != nil { @@ -329,7 +328,7 @@ func ScrapeDivision(index uint32) (*models.Division, error) { return &division, nil } -func ScrapeTeacher(index uint32) (*models.Teacher, error) { +func ScrapeTeacher(index uint64) (*models.Teacher, error) { endpoint := makeTeacherEndpoint(index) doc, err := utils.OpenDoc(Config.BaseUrl, endpoint) if err != nil { @@ -367,7 +366,7 @@ func ScrapeTeacher(index uint32) (*models.Teacher, error) { return &teacher, nil } -func ScrapeRoom(index uint32) (*models.Room, error) { +func ScrapeRoom(index uint64) (*models.Room, error) { endpoint := makeRoomEndpoint(index) doc, err := utils.OpenDoc(Config.BaseUrl, endpoint) if err != nil { @@ -403,13 +402,13 @@ func ScrapeRoom(index uint32) (*models.Room, error) { return &room, nil } -func ScrapeDivisionsIndexes() ([]uint32, error) { +func ScrapeDivisionsIndexes() ([]uint64, error) { doc, err := utils.OpenDoc(Config.BaseUrl, Config.Endpoints.DivisionsList) if err != nil { return nil, fmt.Errorf("error opening document: %w", err) } - indexes := []uint32{} + indexes := []uint64{} doc.Find("a").Each(func(index int, element *goquery.Selection) { href, exists := element.Attr("href") if exists { @@ -421,13 +420,13 @@ func ScrapeDivisionsIndexes() ([]uint32, error) { fmt.Printf("error converting number to uint: %v\n", err) return } - endpoint := makeDivisionEndpoint(uint32(num)) + endpoint := makeDivisionEndpoint(num) _, err = utils.OpenDoc(Config.BaseUrl, endpoint) if err != nil { fmt.Printf("error opening division document: %v\n", err) return } - indexes = append(indexes, uint32(num)) + indexes = append(indexes, num) } } }) @@ -435,13 +434,13 @@ func ScrapeDivisionsIndexes() ([]uint32, error) { return indexes, nil } -func ScrapeTeachersIndexes() ([]uint32, error) { +func ScrapeTeachersIndexes() ([]uint64, error) { doc, err := utils.OpenDoc(Config.BaseUrl, Config.Endpoints.TeachersList) if err != nil { return nil, fmt.Errorf("error opening document: %w", err) } - indexes := []uint32{} + indexes := []uint64{} doc.Find("a").Each(func(index int, element *goquery.Selection) { href, exists := element.Attr("href") @@ -454,13 +453,13 @@ func ScrapeTeachersIndexes() ([]uint32, error) { fmt.Printf("error converting number to uint: %v\n", err) return } - endpoint := makeTeacherEndpoint(uint32(num)) + endpoint := makeTeacherEndpoint(num) _, err = utils.OpenDoc(Config.BaseUrl, endpoint) if err != nil { fmt.Printf("error opening teacher document: %v\n", err) return } - indexes = append(indexes, uint32(num)) + indexes = append(indexes, num) } } }) @@ -468,13 +467,13 @@ func ScrapeTeachersIndexes() ([]uint32, error) { return indexes, nil } -func ScrapeRoomsIndexes() ([]uint32, error) { +func ScrapeRoomsIndexes() ([]uint64, error) { doc, err := utils.OpenDoc(Config.BaseUrl, Config.Endpoints.RoomsList) if err != nil { return nil, fmt.Errorf("error opening document: %w", err) } - indexes := []uint32{} + indexes := []uint64{} doc.Find("a").Each(func(index int, element *goquery.Selection) { href, exists := element.Attr("href") @@ -487,13 +486,13 @@ func ScrapeRoomsIndexes() ([]uint32, error) { fmt.Printf("error converting number to uint: %v\n", err) return } - endpoint := makeRoomEndpoint(uint32(num)) + endpoint := makeRoomEndpoint(num) _, err = utils.OpenDoc(Config.BaseUrl, endpoint) if err != nil { fmt.Printf("error opening room document: %v\n", err) return } - indexes = append(indexes, uint32(num)) + indexes = append(indexes, num) } } }) diff --git a/data.proto b/data.proto index b4edb0d..15cecf5 100644 --- a/data.proto +++ b/data.proto @@ -6,15 +6,15 @@ package data; option go_package = "./common/models"; message DivisionsDesignators { - map divisions = 1; + map divisions = 1; } message TeachersDesignators { - map teachers = 1; + map teachers = 1; } message RoomsDesignators { - map rooms = 1; + map rooms = 1; } message Condition { @@ -23,9 +23,9 @@ message Condition { } message Temperature { - float current = 1; - float min = 2; - float max = 3; + double current = 1; + double min = 2; + double max = 3; } message Forecast { @@ -33,7 +33,7 @@ message Forecast { Temperature temperature = 2; int64 sunrise = 3; int64 sunset = 4; - int32 dayOfWeek = 5; + int64 dayOfWeek = 5; } message ForecastResponse { @@ -50,12 +50,12 @@ message CurrentWeatherResponse { } message AirPollutionResponse { - map components = 1; + map components = 1; } message Timestamp { - int32 hour = 1; - int32 minute = 2; + int64 hour = 1; + int64 minute = 2; } message TimeRange { @@ -84,20 +84,20 @@ message Schedule { } message Teacher { - uint32 index = 1; + uint64 index = 1; string designator = 2; string full_name = 3; Schedule schedule = 4; } message Room { - uint32 index = 1; + uint64 index = 1; string designator = 2; Schedule schedule = 3; } message Division { - uint32 index = 1; + uint64 index = 1; string designator = 2; string full_name = 3; Schedule schedule = 4;