mirror of
https://github.com/He4eT/simple-spaceapi.git
synced 2026-05-04 17:37:24 +00:00
SpaceAPI: sensors: wind: messed types
This commit is contained in:
parent
e14842605a
commit
7c8fa7755d
1 changed files with 20 additions and 23 deletions
|
|
@ -175,7 +175,7 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
|
|||
const getSensorsRaw = (
|
||||
query: UID.ContentType,
|
||||
populate = [],
|
||||
): Promise<Object[]> =>
|
||||
): Promise<Array<object>> =>
|
||||
strapi
|
||||
.documents(query)
|
||||
.findMany({ populate })
|
||||
|
|
@ -278,36 +278,33 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
|
|||
'api::wind-sensor.wind-sensor',
|
||||
['properties', 'location', 'name', 'description', 'lastchange'],
|
||||
[
|
||||
'properties',
|
||||
'properties.speed',
|
||||
'properties.gust',
|
||||
'properties.direction',
|
||||
'properties.elevation',
|
||||
],
|
||||
)
|
||||
).map(
|
||||
(sensor: {
|
||||
properties: { bits_per_second: number; packets_per_second: number };
|
||||
}) => {
|
||||
const { properties, ...rest } = sensor;
|
||||
).map((sensor: { properties: Record<string, object> }) => {
|
||||
const { properties, ...rest } = sensor;
|
||||
|
||||
const propertiesEntries = Object.entries(
|
||||
pickFields(['speed', 'gust', 'direction', 'elevation'])(properties),
|
||||
).map(([k, { value, unit }]) => [
|
||||
k,
|
||||
{
|
||||
value,
|
||||
unit: unit === 'degree' ? '°' : unit,
|
||||
},
|
||||
]);
|
||||
const propertiesEntries = Object.entries(
|
||||
pickFields(['speed', 'gust', 'direction', 'elevation'])(properties),
|
||||
).map(([k, { value, unit }]) => [
|
||||
k,
|
||||
{
|
||||
value,
|
||||
unit: unit === 'degree' ? '°' : unit,
|
||||
},
|
||||
]);
|
||||
|
||||
return {
|
||||
...rest,
|
||||
...(isEmpty(propertiesEntries)
|
||||
? {}
|
||||
: { properties: Object.fromEntries(propertiesEntries) }),
|
||||
};
|
||||
},
|
||||
),
|
||||
return {
|
||||
...rest,
|
||||
...(isEmpty(propertiesEntries)
|
||||
? {}
|
||||
: { properties: Object.fromEntries(propertiesEntries) }),
|
||||
};
|
||||
}),
|
||||
network_connections: (
|
||||
await getSensors(
|
||||
'api::network-connections-sensor.network-connections-sensor',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue