export metric for gnss locations
This commit is contained in:
		| @ -27,6 +27,12 @@ const locationsTotal = new Gauge({ | ||||
|   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({ | ||||
|   name: `${prefix}wifi_locations_total`, | ||||
|   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"); | ||||
|  | ||||
|     locationsTotal.set((await locationService.getAllLocations()).length); | ||||
|     gnssLocationsTotal.set((await locationService.getAllGnssLocations()).length); | ||||
|     wifiLocationTotal.set((await wifiLocationService.getAllWifiLocations()).length); | ||||
|     wifiLocationNotResolvable.set((await wifiLocationService.getAllWifiLocationsByNotResolvable()).length); | ||||
|     wifiLocationRequestLimitExceeded.set((await wifiLocationService.getAllWifiLocationsByRequestLimitExceeded()).length); | ||||
|  | ||||
| @ -1,10 +1,11 @@ | ||||
| import { Attributes, FindOptions } from "sequelize"; | ||||
| import { injectable } from "tsyringe"; | ||||
| import { Location } from "../models/location"; | ||||
|  | ||||
| @injectable() | ||||
| export class LocationRepository { | ||||
|   public async findAll() { | ||||
|     return await Location.findAll(); | ||||
|   public async findAll(options?: FindOptions<Attributes<Location>>) { | ||||
|     return await Location.findAll(options); | ||||
|   } | ||||
|  | ||||
|   public async findById(id: string) { | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { inject, injectable } from "tsyringe"; | ||||
| import { Op } from 'sequelize'; | ||||
| import { Location } from "../models/location"; | ||||
| import { LocationRepository } from "../repositories/locationRepository"; | ||||
| import { WifiLocationService } from "./wifiLocationService"; | ||||
| @ -52,6 +53,15 @@ export class LocationService { | ||||
|     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) { | ||||
|     return this.repository.findById(id); | ||||
|   } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user