This commit is contained in:
2025-09-09 00:10:53 +03:00
parent 38f2a05107
commit 204fc092d7
239 changed files with 22447 additions and 9536 deletions

View File

@@ -30,11 +30,19 @@ class HomesteadsService {
(SELECT homestead_history.date_end FROM homestead_history WHERE homestead_history.homestead_id = homestead.id ORDER BY homestead_history.date_start DESC LIMIT 1) AS homestead_history_date_end
FROM
homestead
WHERE
group_id == '${group}'
JOIN
homestead_history
ON
homestead.id = homestead_history.homestead_id
AND
homestead_history.working = 1
AND
homestead_history.name = 'Групова'
AND
homestead_history.group_id == '${group}'
`;
}
if (sheepName) {
sql = `
SELECT
@@ -52,12 +60,10 @@ class HomesteadsService {
homestead_history
ON
homestead.id = homestead_history.homestead_id
WHERE
homestead.group_id = '${group}'
AND
homestead_history.working = 1
AND
homestead_history.name IN ('Групова', '${sheepName}');
homestead_history.name = '${sheepName}';
`;
}
@@ -69,12 +75,11 @@ class HomesteadsService {
let data = rows.map((row) => {
return {
"id": Number(row.id),
"group_id": Number(row.group_id),
"title": row.title,
"number": row.number,
"points": JSON.parse(row.points),
"point_icons": JSON.parse(row.point_icons),
"geo": JSON.parse(row.geo),
"zoom": Number(row.zoom),
"osm_id": JSON.parse(row.osm_id),
"settlement": row.settlement,
"description": row.description,
@@ -127,12 +132,11 @@ class HomesteadsService {
} else {
let data = {
"id": Number(row.id),
"group_id": Number(row.group_id),
"title": row.title,
"number": row.number,
"points": JSON.parse(row.points),
"point_icons": JSON.parse(row.point_icons),
"geo": JSON.parse(row.geo),
"zoom": Number(row.zoom),
"osm_id": JSON.parse(row.osm_id),
"settlement": row.settlement,
"description": row.description,
@@ -160,27 +164,25 @@ class HomesteadsService {
let sql = `
INSERT INTO
homestead(
group_id,
title,
number,
points,
point_icons,
geo,
zoom,
osm_id,
settlement,
created_at
)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?)
(?, ?, ?, ?, ?, ?, ?, ?)
`;
db.run(sql, [
Number(data.group_id),
data.title,
data.number,
JSON.stringify(data.points),
JSON.stringify(data.point_icons),
JSON.stringify(data.geo),
Number(data.zoom),
JSON.stringify(data.osm_id),
data.settlement,
Math.floor(new Date(Date.now()).getTime())
@@ -203,12 +205,11 @@ class HomesteadsService {
UPDATE
homestead
SET
group_id = ?,
title = ?,
number = ?,
points = ?,
point_icons = ?,
geo = ?,
zoom = ?,
osm_id = ?,
settlement = ?,
description = ?,
@@ -217,12 +218,11 @@ class HomesteadsService {
id = ?
`;
db.run(sql, [
Number(data.group_id),
data.title,
data.number,
JSON.stringify(data.points),
JSON.stringify(data.point_icons),
JSON.stringify(data.geo),
Number(data.zoom),
JSON.stringify(data.osm_id),
data.settlement,
data.description,