@carto/api-client 0.5.9-alpha.PR193.3 → 0.5.9-alpha.orderby.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api-client.cjs +47 -33
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +14 -18
- package/build/api-client.d.ts +14 -18
- package/build/api-client.js +46 -33
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +21 -3
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +21 -3
- package/build/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/api/query.ts +2 -19
- package/src/api/request-with-parameters.ts +5 -10
- package/src/models/model.ts +0 -3
- package/src/operations/groupBy.ts +31 -2
- package/src/sources/base-source.ts +1 -1
- package/src/sources/types.ts +0 -3
- package/src/widget-sources/types.ts +12 -0
- package/src/widget-sources/widget-remote-source.ts +9 -3
- package/src/widget-sources/widget-tileset-source-impl.ts +2 -0
package/build/worker.js
CHANGED
|
@@ -5683,7 +5683,8 @@ function groupValuesByColumn({
|
|
|
5683
5683
|
joinOperation,
|
|
5684
5684
|
keysColumn,
|
|
5685
5685
|
operation: operation2,
|
|
5686
|
-
othersThreshold
|
|
5686
|
+
othersThreshold,
|
|
5687
|
+
orderBy = "frequency_desc"
|
|
5687
5688
|
}) {
|
|
5688
5689
|
if (Array.isArray(data) && data.length === 0) {
|
|
5689
5690
|
return { rows: null };
|
|
@@ -5707,7 +5708,7 @@ function groupValuesByColumn({
|
|
|
5707
5708
|
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
5708
5709
|
name,
|
|
5709
5710
|
value: targetOperation(value)
|
|
5710
|
-
})).sort((
|
|
5711
|
+
})).sort(getSorter(orderBy));
|
|
5711
5712
|
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
5712
5713
|
const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
|
|
5713
5714
|
return {
|
|
@@ -5721,6 +5722,21 @@ function groupValuesByColumn({
|
|
|
5721
5722
|
rows: allCategories
|
|
5722
5723
|
};
|
|
5723
5724
|
}
|
|
5725
|
+
function getSorter(orderBy) {
|
|
5726
|
+
switch (orderBy) {
|
|
5727
|
+
case "frequency_asc":
|
|
5728
|
+
return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
|
|
5729
|
+
case "frequency_desc":
|
|
5730
|
+
return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
|
|
5731
|
+
case "alphabetical_asc":
|
|
5732
|
+
return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
|
|
5733
|
+
case "alphabetical_desc":
|
|
5734
|
+
return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
|
|
5735
|
+
}
|
|
5736
|
+
}
|
|
5737
|
+
function localeCompare(a, b) {
|
|
5738
|
+
return (a ?? "null").localeCompare(b ?? "null");
|
|
5739
|
+
}
|
|
5724
5740
|
|
|
5725
5741
|
// src/utils/dateUtils.ts
|
|
5726
5742
|
function getUTCMonday(date) {
|
|
@@ -6343,6 +6359,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6343
6359
|
filterOwner,
|
|
6344
6360
|
spatialFilter,
|
|
6345
6361
|
othersThreshold,
|
|
6362
|
+
orderBy = "frequency_desc",
|
|
6346
6363
|
rawResult
|
|
6347
6364
|
}) {
|
|
6348
6365
|
const filteredFeatures = this._getFilteredFeatures(
|
|
@@ -6360,7 +6377,8 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6360
6377
|
joinOperation,
|
|
6361
6378
|
keysColumn: column,
|
|
6362
6379
|
operation: operation2,
|
|
6363
|
-
othersThreshold
|
|
6380
|
+
othersThreshold,
|
|
6381
|
+
orderBy
|
|
6364
6382
|
});
|
|
6365
6383
|
if (rawResult) {
|
|
6366
6384
|
return result;
|