Skip to content

Commit

Permalink
Merge branch 'main' into invite-tenant-with-owner-role-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LWangllix authored Feb 21, 2024
2 parents 44577c1 + 4eb4fc5 commit ce6dfb6
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 42 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"nats": "^2.6.0",
"objection": "^3.0.1",
"pg": "^8.10.0",
"postmark": "^3.0.18",
"postmark": "^4.0.2",
"typescript": "^4.5.5"
},
"engines": {
Expand Down
51 changes: 46 additions & 5 deletions services/objects.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
'use strict';

import moleculer, { Context } from 'moleculer';
import moleculer, { Context, RestSchema } from 'moleculer';
import { Action, Service } from 'moleculer-decorators';

import DbConnection from '../mixins/database.mixin';
import { FeatureCollection } from 'geojsonjs';
import { gisConfig } from '../knexfile';
import DbConnection from '../mixins/database.mixin';
import { throwBadRequestError } from '../types';
import { FeatureCollection } from 'geojsonjs';

import { snakeCase } from 'lodash';
import PostgisMixin from 'moleculer-postgis';
import {
getDamOfLandsQuery,
getExcessWaterCulvertQuery,
Expand All @@ -18,8 +20,6 @@ import {
parseToJsonIfNeeded,
} from '../utils';
import { AuthType } from './api.service';
import { snakeCase } from 'lodash';
import PostgisMixin from 'moleculer-postgis';
const tableName = 'publishing.uetkMerged';

export type UETKObject = {
Expand Down Expand Up @@ -258,4 +258,45 @@ export default class ObjectsService extends moleculer.Service {
sort: 'name',
});
}

@Action({
rest: <RestSchema>{
method: 'GET',
basePath: '/public/statistics',
path: '/',
},
auth: AuthType.PUBLIC,
// todo cache
})
async publicStatistics(ctx: Context<{}>) {
const UETKObjects: UETKObject[] = await ctx.call('objects.find');

return UETKObjects.reduce((groupedUETKObjects, currentUETKObject) => {
groupedUETKObjects[currentUETKObject?.category] =
groupedUETKObjects?.[currentUETKObject?.category] || {};

groupedUETKObjects[currentUETKObject?.category].count =
(groupedUETKObjects[currentUETKObject.category]?.count || 0) + 1;

if (currentUETKObject?.area) {
groupedUETKObjects[currentUETKObject?.category].area = Number(
(
(groupedUETKObjects[currentUETKObject.category]?.area || 0) +
currentUETKObject.area / 10000
).toFixed(2)
); // convert to ha
}

if (currentUETKObject?.length) {
groupedUETKObjects[currentUETKObject?.category].length = Number(
(
(groupedUETKObjects[currentUETKObject.category]?.length || 0) +
currentUETKObject.length / 1000
).toFixed(2)
); // convert to km
}

return groupedUETKObjects;
}, {} as { [key: string]: { count?: number; length?: number; area?: number } });
}
}
8 changes: 2 additions & 6 deletions templates/includes/extra/matavimo-stotys-upes.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<tr>
<td>Upės baseino plotas ties stotimi:</td>
<td class="font-bold">
<%= roundNumber(item.nulineAltitude, 1) || '-' %> km<sup>2</sup>
<%= roundNumber(item.baseino_plotas, 1) || '-' %> km<sup>2</sup>
</td>
</tr>
<tr>
Expand All @@ -33,11 +33,7 @@
</tr>
<tr>
<td>Stebima nuo:</td>
<td class="font-bold"><%= formatDate(item.stebejimu_pradzia) || '-' %></td>
</tr>
<tr>
<td>Duomenų teikėjas:</td>
<td class="font-bold"><%= item.saltinis %></td>
<td class="font-bold"><%= item.stebejimu_pradzia || '-' %></td>
</tr>
<% }); %>
</table>
11 changes: 3 additions & 8 deletions templates/includes/extra/matavimo-stotys.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</tr>
<tr>
<td>Pavadinimas:</td>
<td class="font-bold" ><%= item.pavadinimas %></td>
<td class="font-bold"><%= item.pavadinimas %></td>
</tr>
<tr>
<td>Koordinatė X (LKS94):</td>
Expand All @@ -17,16 +17,11 @@
</tr>
<tr>
<td>Stoties atskaitos nulinė altitudė:</td>
<td class="font-bold"><%= roundNumber(item.nulineAltitude, 1) || '-' %> m</td>
<td class="font-bold"><%= roundNumber(item.altitude, 1) || '-' %> m</td>
</tr>
<tr>
<td>Hidrometrinių stebėjimų laikotarpio pradžia:</td>
<td class="font-bold"><%= formatDate(item.stebejimu_pradzia) || '-' %></td>
</tr>
<tr>
<td>Duomenų teikėjas:</td>
<td class="font-bold"><%= item.saltinis %></td>
<td class="font-bold"><%= item.stebejimu_pradzia || '-' %></td>
</tr>
<% }); %>
</table>
11 changes: 4 additions & 7 deletions templates/includes/extra/tyrimo-vietos.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
<% if (locals.showDistance) { %>
<tr>
<td>Atstumas nuo upės žiočių:</td>
<td class="font-bold"><%= roundNumber(item.atstumas_nuo_ziociu, 1) || '-' %> km</td>
<td class="font-bold">
<%= roundNumber(item.atstumas_nuo_ziociu, 1) || '-' %> km
</td>
</tr>
<% } %>
<tr>
<td>Duomenų teikėjas:</td>
<td class="font-bold"><%= item.saltinis || '' %></td>
</tr>
<% }); %>
<% } %> <% }); %>
</table>
1 change: 1 addition & 0 deletions utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function getObjectByCadastralId(

export function roundNumber(number: string, digits: number = 2) {
if (!number) return;

let numberParsed = parseFloat(number);

if (Number.isNaN(numberParsed)) return;
Expand Down
45 changes: 30 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1355,12 +1355,14 @@ available-typed-arrays@^1.0.5:
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==

axios@^0.25.0:
version "0.25.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.25.0.tgz#349cfbb31331a9b4453190791760a8d35b093e0a"
integrity sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==
axios@^1.6.2:
version "1.6.7"
resolved "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz#7b48c2e27c96f9c68a2f8f31e2ab19f59b06b0a7"
integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==
dependencies:
follow-redirects "^1.14.7"
follow-redirects "^1.15.4"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

babel-jest@^27.5.1:
version "27.5.1"
Expand Down Expand Up @@ -1438,7 +1440,6 @@ base64-js@^1.3.1:
resolved "https://codeload.github.com/DadPatch/biip-auth-nodejs/tar.gz/45a9e7d0051bde0e247d735948faf16c967e2422"
dependencies:
isomorphic-unfetch "^3.1.0"
qs "^6.11.2"

bl@^4.1.0:
version "4.1.0"
Expand Down Expand Up @@ -2604,10 +2605,10 @@ flatted@^3.2.7:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.9.tgz#7eb4c67ca1ba34232ca9d2d93e9886e611ad7daf"
integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==

follow-redirects@^1.14.7:
version "1.15.4"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf"
integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==
follow-redirects@^1.15.4:
version "1.15.5"
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==

for-each@^0.3.3:
version "0.3.3"
Expand All @@ -2625,6 +2626,15 @@ form-data@^3.0.0:
combined-stream "^1.0.8"
mime-types "^2.1.12"

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

[email protected], fresh@^0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
Expand Down Expand Up @@ -4834,12 +4844,12 @@ postgres-interval@^1.1.0:
dependencies:
xtend "^4.0.0"

postmark@^3.0.18:
version "3.0.19"
resolved "https://registry.yarnpkg.com/postmark/-/postmark-3.0.19.tgz#3cdf9c213b5e642c5497a676ee5a5aa964bd5917"
integrity sha512-ujO8OnL1P60qXCwqLrsQqB4aGHaxrvYP3+wCLilUthKmAv9q88nMFHw5VganNljPmzurrVwvyczQc3AUijP2aw==
postmark@^4.0.2:
version "4.0.2"
resolved "https://registry.npmjs.org/postmark/-/postmark-4.0.2.tgz#0c0410ac427d85f2a43454360cf8d07e0fbda317"
integrity sha512-2zlCv+KVVQ0KoamXZHE7d+gXzLlr8tPE+PxQmtUaIZhbHzZAq4D6yH2b+ykhA8wYCc5ISodcx8U1aNLenXBs9g==
dependencies:
axios "^0.25.0"
axios "^1.6.2"

prelude-ls@^1.2.1:
version "1.2.1"
Expand Down Expand Up @@ -4902,6 +4912,11 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.5"

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

psl@^1.1.33:
version "1.9.0"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"
Expand Down

0 comments on commit ce6dfb6

Please sign in to comment.