Class: SiteService
Defined in: electron/services/site/SiteService.ts:44
Service for coordinating site operations across multiple repositories.
Remarks
Handles complex operations that require coordination between site, monitor, and history data. Provides atomic deletion, detailed loading, and batch operations for sites and their related entities.
Constructors
Constructor
new SiteService(
dependencies
:SiteServiceDependencies
):SiteService
Defined in: electron/services/site/SiteService.ts:294
Constructs a new SiteService instance.
Parameters
dependencies
The SiteServiceDependencies required for service operations.
Returns
SiteService
Properties
DEFAULT_SITE_NAME
private
readonly
static
DEFAULT_SITE_NAME:"Unnamed Site"
="Unnamed Site"
Defined in: electron/services/site/SiteService.ts:55
Internal
Default name for sites when no name is provided.
Remarks
Used as a fallback when a site does not have a name in the database.
Default Value
"Unnamed Site"
@internal
databaseService
private
readonly
databaseService:DatabaseService
Defined in: electron/services/site/SiteService.ts:57
historyRepository
private
readonly
historyRepository:HistoryRepository
Defined in: electron/services/site/SiteService.ts:59
monitorRepository
private
readonly
monitorRepository:MonitorRepository
Defined in: electron/services/site/SiteService.ts:61
siteRepository
private
readonly
siteRepository:SiteRepository
Defined in: electron/services/site/SiteService.ts:63
Methods
deleteSiteWithRelatedData()
deleteSiteWithRelatedData(
identifier
:string
):Promise
<boolean
>
Defined in: electron/services/site/SiteService.ts:81
Deletes a site and all its related data (monitors and history) atomically.
Parameters
identifier
string
The site identifier to delete.
Returns
Promise
<boolean
>
Promise resolving to true if all deletions succeeded.
Remarks
Uses a transaction to ensure atomicity. Deletes all monitor history, monitors, and the site itself. Throws if any operation fails.
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Error when any deletion operation fails.
findByIdentifierWithDetails()
findByIdentifierWithDetails(
identifier
:string
):Promise
<undefined
|Site
>
Defined in: electron/services/site/SiteService.ts:173
Finds a site by identifier with all related monitors and history data.
Parameters
identifier
string
The site identifier to find.
Returns
Promise resolving to the site with details, or undefined if not found.
Remarks
Replaces the complex logic that was previously in SiteRepository. Loads the site, its monitors, and all monitor history in a single operation.
getAllWithDetails()
Defined in: electron/services/site/SiteService.ts:239
Gets all sites with their related monitors and history data.
Returns
Promise resolving to an array of sites with complete data.
Remarks
Replaces the complex logic that was previously in SiteRepository. Optimized to fetch monitor history in parallel for better performance. Returns all sites with complete details.
getDisplayName()
private
getDisplayName(siteName
:undefined
|null
|string
):string
Defined in: electron/services/site/SiteService.ts:313
Internal
Gets the display name for a site, using the default if none is provided.
Parameters
siteName
The site name from the database.
undefined
| null
| string
Returns
string
Display name with fallback to the default.
Remarks
Used internally to ensure all sites have a displayable name.