11export default class HealthCheck {
2- constructor ( config , loggerService , blueskyService , unsplashService ,
3- pluginsCommonService , grBirdApiService , logsService ) {
2+ constructor ( config , loggerService , blueskyService , plantnetApiService , pluginsCommonService , logsService ) {
43 this . isAvailable = false ;
54 this . logger = loggerService . getLogger ( ) . child ( { label : 'HealthCheck' } ) ;
65 this . blueskyService = blueskyService ;
7- this . unsplashService = unsplashService ;
6+ this . plantnetApiService = plantnetApiService ;
87 this . pluginsCommonService = pluginsCommonService ;
9- this . grBirdApiService = grBirdApiService ;
108 this . logsService = logsService ;
119 try {
12- this . isAvailable = unsplashService . isReady ( ) ;
10+ this . isAvailable = plantnetApiService . isReady ( ) ;
1311 this . logger . info ( ( this . isAvailable ? "available" : "not available" ) ) ;
1412 } catch ( exception ) {
1513 this . pluginsCommonService . logError ( "init" , exception ) ;
@@ -34,8 +32,11 @@ export default class HealthCheck {
3432 const { logger, pluginsCommonService} = this ;
3533 logger . info ( `healthCheck - doSimulate:${ doSimulate } - context:${ JSON . stringify ( context ) } ` ) ;
3634 let errorCount = 0 ;
35+
36+ /***************************** Checks *******************************************************/
3737 errorCount = await this . checkLogs ( errorCount ) ;
3838 errorCount = await this . checkBlueskySearch ( errorCount ) ;
39+ errorCount = await this . checkPlantNetID ( config , errorCount ) ;
3940
4041 const sentence = pluginName + ( errorCount > 0 ? `❌ done with ${ errorCount } errors.` : "✅ done without issue." ) ;
4142 return await pluginsCommonService . resultSimple ( pluginName , context , sentence ) ;
@@ -78,12 +79,40 @@ export default class HealthCheck {
7879 return errorCount ;
7980 }
8081
82+ async checkPlantNetID ( config , errorCount ) {
83+ const start = Date . now ( ) ;
84+ const target = "plantnetApiService.plantnetIdentify" ;
85+ try {
86+ const { doSimulate, context} = config ;
87+ const imageUrl = "https://cdn.bsky.app/img/feed_fullsize/plain/did:plc:bjivtavjwicclemh6xsotprl/bafkreib6aziube7wpdu2c7dhbgdbeofilny2faornvbhj23n6w7g7nzege@jpeg"
88+ const {
89+ result,
90+ plantnetResult = null
91+ } = await this . plantnetApiService . plantnetIdentify ( {
92+ imageUrl, // candidatePhoto?.fullsize,
93+ "doSimulate" : false ,
94+ "doSimulateIdentify" : doSimulate ,
95+ "simulateIdentifyCase" : 'GoodScoreImages' ,
96+ context
97+ } ) ;
98+ this . reportSuccess ( target , Date . now ( ) - start ,
99+ `result : ${ JSON . stringify ( { result, plantnetResult} ) } ` ) ;
100+ } catch ( error ) {
101+ errorCount ++ ;
102+ this . reportError ( target , Date . now ( ) - start , error )
103+ }
104+ return errorCount ;
105+
106+
107+ }
108+
81109 reportSuccess ( target , durationMs , successMsg ) {
82110 this . logger . info ( `🧪✅ healthCheck - ${ target } (${ durationMs } ms) ${ successMsg } ` ) ;
83111 }
84112
85113 reportError ( target , durationMs , error ) {
86114 this . logger . info ( `🧪❌ healthCheck - ${ target } (${ durationMs } ms) error: ${ error . message } ` ) ;
87115 }
116+
88117}
89118
0 commit comments