export metric for gnss locations
This commit is contained in:
parent
79580e16b7
commit
34167c4d99
@ -27,6 +27,12 @@ const locationsTotal = new Gauge({
|
|||||||
labelNames: ["database"],
|
labelNames: ["database"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const gnssLocationsTotal = new Gauge({
|
||||||
|
name: `${prefix}gnss_locations_total`,
|
||||||
|
help: "Total number of location entries with GNSS in database",
|
||||||
|
labelNames: ["database"],
|
||||||
|
});
|
||||||
|
|
||||||
const wifiLocationTotal = new Gauge({
|
const wifiLocationTotal = new Gauge({
|
||||||
name: `${prefix}wifi_locations_total`,
|
name: `${prefix}wifi_locations_total`,
|
||||||
help: "Total number of wifi location entries in database",
|
help: "Total number of wifi location entries in database",
|
||||||
@ -58,6 +64,7 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
console.log("Metric Endpoint triggered");
|
console.log("Metric Endpoint triggered");
|
||||||
|
|
||||||
locationsTotal.set((await locationService.getAllLocations()).length);
|
locationsTotal.set((await locationService.getAllLocations()).length);
|
||||||
|
gnssLocationsTotal.set((await locationService.getAllGnssLocations()).length);
|
||||||
wifiLocationTotal.set((await wifiLocationService.getAllWifiLocations()).length);
|
wifiLocationTotal.set((await wifiLocationService.getAllWifiLocations()).length);
|
||||||
wifiLocationNotResolvable.set((await wifiLocationService.getAllWifiLocationsByNotResolvable()).length);
|
wifiLocationNotResolvable.set((await wifiLocationService.getAllWifiLocationsByNotResolvable()).length);
|
||||||
wifiLocationRequestLimitExceeded.set((await wifiLocationService.getAllWifiLocationsByRequestLimitExceeded()).length);
|
wifiLocationRequestLimitExceeded.set((await wifiLocationService.getAllWifiLocationsByRequestLimitExceeded()).length);
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
import { Attributes, FindOptions } from "sequelize";
|
||||||
import { injectable } from "tsyringe";
|
import { injectable } from "tsyringe";
|
||||||
import { Location } from "../models/location";
|
import { Location } from "../models/location";
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class LocationRepository {
|
export class LocationRepository {
|
||||||
public async findAll() {
|
public async findAll(options?: FindOptions<Attributes<Location>>) {
|
||||||
return await Location.findAll();
|
return await Location.findAll(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async findById(id: string) {
|
public async findById(id: string) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { inject, injectable } from "tsyringe";
|
import { inject, injectable } from "tsyringe";
|
||||||
|
import { Op } from 'sequelize';
|
||||||
import { Location } from "../models/location";
|
import { Location } from "../models/location";
|
||||||
import { LocationRepository } from "../repositories/locationRepository";
|
import { LocationRepository } from "../repositories/locationRepository";
|
||||||
import { WifiLocationService } from "./wifiLocationService";
|
import { WifiLocationService } from "./wifiLocationService";
|
||||||
@ -52,6 +53,15 @@ export class LocationService {
|
|||||||
return this.repository.findAll();
|
return this.repository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getAllGnssLocations() {
|
||||||
|
return this.repository.findAll({
|
||||||
|
where: {
|
||||||
|
gnss_latitude: { [Op.ne]: null },
|
||||||
|
gnss_longitude: { [Op.ne]: null }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public async getLocationById(id: string) {
|
public async getLocationById(id: string) {
|
||||||
return this.repository.findById(id);
|
return this.repository.findById(id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user