File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -98,3 +98,36 @@ class ExternalApi extends Callable {
98
98
99
99
/** DEPRECATED: Alias for ExternalApi */
100
100
deprecated class ExternalAPI = ExternalApi ;
101
+
102
+ /**
103
+ * A limit for the number of results produced by a telemetry query.
104
+ */
105
+ int resultLimit ( ) { result = 1000 }
106
+
107
+ /**
108
+ * A predicate signature for relevant usage counts of an External API `api`.
109
+ */
110
+ signature predicate relevantUsagesSig ( ExternalApi api , int usages ) ;
111
+
112
+ /**
113
+ * Given a predicate to count relevant API usages, this module provides a predicate
114
+ * for restricting the number or returned results based on a certain limit.
115
+ */
116
+ module Results< relevantUsagesSig / 2 getRelevantUsages> {
117
+ private int getOrder ( ExternalApi api ) {
118
+ api =
119
+ rank [ result ] ( ExternalApi a , int usages |
120
+ getRelevantUsages ( a , usages )
121
+ |
122
+ a order by usages desc , a .getApiName ( )
123
+ )
124
+ }
125
+
126
+ /**
127
+ * Holds if `api` is being used `usages` times and if it is
128
+ * in the top results (guarded by resultLimit).
129
+ */
130
+ predicate restrict ( ExternalApi api , int usages ) {
131
+ getRelevantUsages ( api , usages ) and getOrder ( api ) <= resultLimit ( )
132
+ }
133
+ }
You can’t perform that action at this time.
0 commit comments