Skip to content

Commit c33fef3

Browse files
authored
Merge pull request #78 from intersystems-community/add-search-result-properties
add allversions, manifest, origin to search result
2 parents 32b5117 + 9a17024 commit c33fef3

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

module.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<Document name="zpm-registry.ZPM">
44
<Module>
55
<Name>zpm-registry</Name>
6+
<ExternalName>ZPM Registry</ExternalName>
67
<Description>Registry server for ZPM</Description>
7-
<Version>1.1.5</Version>
8+
<Version>1.1.6</Version>
89
<Packaging>module</Packaging>
910
<Dependencies>
1011
<ModuleReference>

src/cls/ZPM/Package.cls

+26-2
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ ClassMethod LoadFromGitHub(Url = "")
513513
}
514514

515515
/// returns latest versions of packages
516-
ClassMethod GetLatest(searchTerms As %DynamicArray = "", Output pStatus As %Status) As %DynamicArray
516+
ClassMethod GetLatest(searchTerms As %DynamicArray = "", manifest As %String = "", allVersions As %String = "", Output pStatus As %Status) As %DynamicArray
517517
{
518518
Set pStatus = 1
519519
If ( '($CLASSNAME(searchTerms)="%Library.DynamicArray" ) || (searchTerms.%Size()=0) ) {
@@ -536,8 +536,9 @@ ClassMethod GetLatest(searchTerms As %DynamicArray = "", Output pStatus As %Stat
536536
}
537537
Set searchCondition = searchCondition_ " ) "
538538
}
539-
set sql = "SELECT name, repository, description, version "_
539+
set sql = "SELECT p1.name, p1.repository, p1.description, p1.version, ul.Host "_
540540
" FROM ZPM.Package p1 "_
541+
" LEFT JOIN ZPM.UpLink ul ON ul.ID = p1.UpLink " _
541542
" WHERE "_searchCondition_" "_
542543
" AND p1.version = ( SELECT TOP 1 version FROM ZPM.Package p2 WHERE p1.name=p2.name ORDER BY versionMajor DESC, versionMinor DESC, versionPatch DESC, versionPrerelease DESC, versionBuildmetadata DESC ) "
543544

@@ -558,8 +559,31 @@ ClassMethod GetLatest(searchTerms As %DynamicArray = "", Output pStatus As %Stat
558559
"name": (tResult.name),
559560
"description": (tResult.description),
560561
"repository": (tResult.repository),
562+
"origin": (tResult.Host),
561563
"versions": [(tResult.version)]
562564
}
565+
566+
If (manifest = "1") {
567+
Set tPkgInfo.manifest = ""
568+
Set package = ##class(ZPM.Package).%OpenId(tResult.name_"||"_tResult.version)
569+
If ($IsObject(package.manifest)) {
570+
while ('package.manifest.AtEnd) {
571+
Set tPkgInfo.manifest = tPkgInfo.manifest _ package.manifest.Read(100)
572+
}
573+
}
574+
}
575+
576+
If (allVersions = "1") {
577+
Set tPkgInfo.allVersions = []
578+
Set sql2 = "SELECT version "_
579+
" FROM ZPM.Package WHERE name = ? "_
580+
" ORDER BY versionMajor DESC, versionMinor DESC, versionPatch DESC, versionPrerelease DESC, versionBuildmetadata DESC"
581+
Set versionsResult = ##class(%SQL.Statement).%ExecDirect(, sql2, tResult.name)
582+
While versionsResult.%Next() {
583+
Do tPkgInfo.allVersions.%Push(versionsResult.version)
584+
}
585+
}
586+
563587
do tList.%Push(tPkgInfo)
564588
}
565589
Return tList

src/cls/ZPM/Registry.cls

+3-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ ClassMethod AllPackages() As %Status
238238
} Catch ex {}
239239
$$$ThrowOnError(##class(ZPM.UpLink).UpdatePackagesFromAllUpLinks())
240240

241-
Set tList = ##class(ZPM.Package).GetLatest(searchTerms, .tSC)
241+
Set manifest = %request.Get("manifest","")
242+
Set allVersions = %request.Get("allVersions","")
243+
Set tList = ##class(ZPM.Package).GetLatest(searchTerms, manifest, allVersions, .tSC)
242244

243245
If ($$$ISERR(tSC)) {
244246
Return ..ReportHttpStatusCode(..#HTTP400BADREQUEST, tSC)

0 commit comments

Comments
 (0)