/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 2 2 Ġdz iko ys k Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . repos il ite . statistics . infrastructure Ċ Ċ import Ġcom . repos il ite . statistics . MAX _ PAGE _ SIZE Ċ import Ġcom . repos il ite . statistics . Statistics Facade Ċ import Ġcom . repos il ite . statistics . api . Resolved Count Response Ċ import Ġcom . repos il ite . web . api . Repos il ite Route Ċ import Ġcom . repos il ite . web . api . Repos il ite Routes Ċ import Ġcom . repos il ite . web . http . ErrorResponse Ċ import Ġcom . repos il ite . web . routing . Route Method . GET Ċ import Ġio . jav al in . openapi . HttpMethod Ċ import Ġio . jav al in . openapi . Open Api Ċ import Ġio . jav al in . openapi . Open Api Content Ċ import Ġio . jav al in . openapi . Open Api Param Ċ import Ġio . jav al in . openapi . Open ApiResponse Ċ import Ġp anda . std . as Success Ċ Ċ internal Ġclass ĠStatistics Endpoint ( private Ġval Ġstatistics Facade : ĠStatistics Facade ) Ġ: ĠRe pos il ite Routes () Ġ{ ĊĊĠĠĠ Ġ@ Open Api ( ĊĠĠĠĠĠĠĠ Ġtags Ġ= Ġ[" Statistics "], ĊĠĠĠĠĠĠĠ Ġpath Ġ= Ġ"/ api / statistics / resolved / phrase /{ limit }/{ repository } /* ", ĊĠĠĠĠĠĠĠ Ġmethods Ġ= Ġ[ HttpMethod . GET ], ĊĠĠĠĠĠĠĠ ĠpathParams Ġ= Ġ[ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠOpen Api Param ( name Ġ= Ġ" limit ", Ġdescription Ġ= Ġ" Amount Ġof Ġrecords Ġto Ġfind Ġ( Maximum : Ġ$ MAX _ PAGE _ SIZE ", Ġrequired Ġ= Ġtrue ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠOpen Api Param ( name Ġ= Ġ" repository ", Ġdescription Ġ= Ġ" Repository Ġto Ġsearch Ġin ", Ġrequired Ġ= Ġtrue ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠOpen Api Param ( name Ġ= Ġ"*", Ġdescription Ġ= Ġ" Phrase Ġto Ġsearch Ġfor ", Ġrequired Ġ= Ġtrue , Ġallow Empty Value Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ], ĊĠĠĠĠĠĠĠ Ġresponses Ġ= Ġ[ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠOpen ApiResponse (" 2 0 0 ", Ġcontent Ġ= Ġ[ ĠOpen Api Content ( from Ġ= ĠResolved Count Response :: class ) Ġ], Ġdescription Ġ= Ġ" Ag gregated Ġsum Ġof Ġresolved Ġrequests Ġwith Ġlist Ġa Ġlist Ġof Ġthem Ġall "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠOpen ApiResponse (" 4 0 1 ", Ġcontent Ġ= Ġ[ ĠOpen Api Content ( from Ġ= ĠError Response :: class ) Ġ], Ġdescription Ġ= Ġ" When Ġinvalid Ġtoken Ġis Ġused ") ĊĠĠĠĠĠĠĠ Ġ] ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġfind Count By Phrase Ġ= ĠRe pos il ite Route < Resolved Count Response > ("/ api / statistics / resolved / phrase /{ limit }/{ repository }/ < g av >", ĠGET ) Ġ{ ĊĠĠĠĠĠĠĠ Ġauthorized ("/ ${ require Parameter (" repository ") }/${ require Parameter (" g av ") }") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse Ġ= Ġstatistics Facade . find Resolved Requests By Phrase ( require Parameter (" repository "), Ġrequire Parameter (" g av "), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Open Api ( ĊĠĠĠĠĠĠĠ Ġtags Ġ= Ġ[" Statistics "], ĊĠĠĠĠĠĠĠ Ġpath Ġ= Ġ"/ api / statistics / resolved / unique ", ĊĠĠĠĠĠĠĠ Ġmethods Ġ= Ġ[ HttpMethod . GET ], ĊĠĠĠĠĠĠĠ Ġresponses Ġ= Ġ[ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠOpen ApiResponse (" 2 0 0 ", Ġcontent Ġ= Ġ[ ĠOpen Api Content ( from Ġ= ĠLong :: class ) Ġ], Ġdescription Ġ= Ġ" Number Ġof Ġall Ġunique Ġrequests "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠOpen ApiResponse (" 4 0 1 ", Ġcontent Ġ= Ġ[ ĠOpen Api Content ( from Ġ= ĠError Response :: class ) Ġ], Ġdescription Ġ= Ġ" When Ġnon - manager Ġtoken Ġis Ġused ") ĊĠĠĠĠĠĠĠ Ġ] ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġfind Unique Count Ġ= ĠRe pos il ite Route < Long > ("/ api / statistics / resolved / unique ", ĠGET ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmanager Only Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse Ġ= Ġstatistics Facade . count Unique Records (). as Success () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval Ġroutes Ġ= Ġroutes ( find Count By Phrase , Ġfind Unique Count ) Ċ Ċ }