show lot occupancy count on dashboard

deepsource-autofix-76c6eb20
Dan Gowans 2023-02-03 12:44:20 -05:00
parent 01c086da96
commit 90c107b0f3
6 changed files with 45 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import { dateToString } from '@cityssm/expressjs-server-js/dateTimeFns.js';
import { getWorkOrderMilestones } from '../../helpers/lotOccupancyDB/getWorkOrderMilestones.js';
import { getWorkOrders } from '../../helpers/lotOccupancyDB/getWorkOrders.js';
import { getLotOccupancies } from '../../helpers/lotOccupancyDB/getLotOccupancies.js';
export async function handler(_request, response) {
const currentDateString = dateToString(new Date());
const workOrderMilestones = await getWorkOrderMilestones({
@ -16,10 +17,20 @@ export async function handler(_request, response) {
limit: 1,
offset: 0
});
const lotOccupancyResults = await getLotOccupancies({
occupancyStartDateString: currentDateString
}, {
limit: 1,
offset: 0,
includeFees: false,
includeOccupants: false,
includeTransactions: false
});
response.render('dashboard', {
headTitle: 'Dashboard',
workOrderMilestones,
workOrderCount: workOrderResults.count
workOrderCount: workOrderResults.count,
lotOccupancyCount: lotOccupancyResults.count
});
}
export default handler;

View File

@ -4,8 +4,12 @@ import { dateToString } from '@cityssm/expressjs-server-js/dateTimeFns.js'
import { getWorkOrderMilestones } from '../../helpers/lotOccupancyDB/getWorkOrderMilestones.js'
import { getWorkOrders } from '../../helpers/lotOccupancyDB/getWorkOrders.js'
import { getLotOccupancies } from '../../helpers/lotOccupancyDB/getLotOccupancies.js'
export async function handler(_request: Request, response: Response): Promise<void> {
export async function handler(
_request: Request,
response: Response
): Promise<void> {
const currentDateString = dateToString(new Date())
const workOrderMilestones = await getWorkOrderMilestones(
@ -24,15 +28,29 @@ export async function handler(_request: Request, response: Response): Promise<vo
workOrderOpenDateString: currentDateString
},
{
limit: 1,
limit: 1, // only using the count
offset: 0
}
)
const lotOccupancyResults = await getLotOccupancies(
{
occupancyStartDateString: currentDateString
},
{
limit: 1, // only using the count
offset: 0,
includeFees: false,
includeOccupants: false,
includeTransactions: false
}
)
response.render('dashboard', {
headTitle: 'Dashboard',
workOrderMilestones,
workOrderCount: workOrderResults.count
workOrderCount: workOrderResults.count,
lotOccupancyCount: lotOccupancyResults.count
})
}

View File

@ -3,9 +3,9 @@ import { dateIntegerToString, dateStringToInteger } from '@cityssm/expressjs-ser
import * as configFunctions from '../functions.config.js';
import { getOccupancyTypeById } from '../functions.cache.js';
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
import { getLotOccupancyFees } from './getLotOccupancyFees.js';
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js';
import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../functions.sqlFilters.js';
import getLotOccupancyFees from './getLotOccupancyFees.js';
import getLotOccupancyTransactions from './getLotOccupancyTransactions.js';
function buildWhereClause(filters) {
let sqlWhereClause = ' where o.recordDelete_timeMillis is null';
const sqlParameters = [];

View File

@ -11,16 +11,18 @@ import {
import * as configFunctions from '../functions.config.js'
import { getOccupancyTypeById } from '../functions.cache.js'
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
import type * as recordTypes from '../../types/recordTypes'
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
import { getLotOccupancyFees } from './getLotOccupancyFees.js'
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js'
import {
getLotNameWhereClause,
getOccupancyTimeWhereClause,
getOccupantNameWhereClause
} from '../functions.sqlFilters.js'
import getLotOccupancyFees from './getLotOccupancyFees.js'
import getLotOccupancyTransactions from './getLotOccupancyTransactions.js'
import type * as recordTypes from '../../types/recordTypes'
interface GetLotOccupanciesFilters {
lotId?: number | string

View File

@ -224,4 +224,4 @@ span.button.is-static {
&.is-visible-hover {
visibility: visible !important;
}
}
}

View File

@ -155,6 +155,9 @@
<span class="fa-layers fa-4x fa-fw" aria-hidden="true">
<i class="fas fa-vector-square"></i>
<i class="fas fa-user" data-fa-transform="shrink-10"></i>
<% if (lotOccupancyCount > 0) { %>
<span class="fa-layers-counter has-background-success"><%= lotOccupancyCount %></span>
<% } %>
</span>
</div>
<div class="media-content has-text-black">