Skip to content

Commit

Permalink
🎨 The database supports calculating the "Percent unique values" of th…
Browse files Browse the repository at this point in the history
…e field #13192
  • Loading branch information
88250 committed Nov 20, 2024
1 parent 36df3d5 commit 1e28680
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 20 deletions.
2 changes: 2 additions & 0 deletions app/appearance/langs/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "NICHT LEER",
"calcResultPercentEmpty": "LEER",
"calcResultPercentNotEmpty": "NICHT LEER",
"calcResultPercentUniqueValues": "Prozent einzigartige Werte",
"calcResultSum": "SUMME",
"calcResultAverage": "DURCHSCHNITT",
"calcResultMedian": "MEDIAN",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "Nicht leer zählen",
"calcOperatorPercentEmpty": "Prozent leer",
"calcOperatorPercentNotEmpty": "Prozent nicht leer",
"calcOperatorPercentUniqueValues": "Prozent einzigartige Werte",
"calcOperatorSum": "Summe",
"calcOperatorAverage": "Durchschnitt",
"calcOperatorMedian": "Median",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "NOT EMPTY",
"calcResultPercentEmpty": "EMPTY",
"calcResultPercentNotEmpty": "NOT EMPTY",
"calcResultPercentUniqueValues": "Percent unique values",
"calcResultSum": "SUM",
"calcResultAverage": "AVERAGE",
"calcResultMedian": "MEDIAN",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "Count not empty",
"calcOperatorPercentEmpty": "Percent empty",
"calcOperatorPercentNotEmpty": "Percent not empty",
"calcOperatorPercentUniqueValues": "Percent unique values",
"calcOperatorSum": "Sum",
"calcOperatorAverage": "Average",
"calcOperatorMedian": "Median",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "NO VACÍO",
"calcResultPercentEmpty": "VACÍO",
"calcResultPercentNotEmpty": "NO VACÍO",
"calcResultPercentUniqueValues": "Porcentaje de valores únicos",
"calcResultSum": "SUMA",
"calcResultAverage": "PROMEDIO",
"calcResultMedian": "MEDIANA",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "Cuenta no vacía",
"calcOperatorPercentEmpty": "Porcentaje vacío",
"calcOperatorPercentNotEmpty": "Porcentaje no vacío",
"calcOperatorPercentUniqueValues": "Porcentaje de valores únicos",
"calcOperatorSum": "Suma",
"calcOperatorAverage": "Promedio",
"calcOperatorMedian": "Mediana",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "NON VIDE",
"calcResultPercentEmpty": "VIDE",
"calcResultPercentNotEmpty": "NON VIDE",
"calcResultPercentUniqueValues": "Pourcentage de valeurs uniques",
"calcResultSum": "SOMME",
"calcResultAverage": "MOYENNE",
"calcResultMedian": "MÉDIANE",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "Compter non vide",
"calcOperatorPercentEmpty": "Pourcentage vide",
"calcOperatorPercentNotEmpty": "Pourcentage non vide",
"calcOperatorPercentUniqueValues": "Pourcentage de valeurs uniques",
"calcOperatorSum": "Somme",
"calcOperatorAverage": "Moyenne",
"calcOperatorMedian": "Médiane",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/he_IL.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "לא ריק",
"calcResultPercentEmpty": "ריק",
"calcResultPercentNotEmpty": "לא ריק",
"calcResultPercentUniqueValues": "אחוז ערכים ייחודיים",
"calcResultSum": "סכום",
"calcResultAverage": "ממוצע",
"calcResultMedian": "חציון",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "ספור לא ריקים",
"calcOperatorPercentEmpty": "אחוז ריקים",
"calcOperatorPercentNotEmpty": "אחוז לא ריקים",
"calcOperatorPercentUniqueValues": "אחוז ערכים ייחודיים",
"calcOperatorSum": "סכום",
"calcOperatorAverage": "ממוצע",
"calcOperatorMedian": "חציון",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "NON VUOTO",
"calcResultPercentEmpty": "VUOTO",
"calcResultPercentNotEmpty": "NON VUOTO",
"calcResultPercentUniqueValues": "Percentuale di valori unici",
"calcResultSum": "SOMMA",
"calcResultAverage": "MEDIA",
"calcResultMedian": "MEDIANA",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "Conta non vuoti",
"calcOperatorPercentEmpty": "Percentuale vuoti",
"calcOperatorPercentNotEmpty": "Percentuale non vuoti",
"calcOperatorPercentUniqueValues": "Percentuale di valori unici",
"calcOperatorSum": "Somma",
"calcOperatorAverage": "Media",
"calcOperatorMedian": "Mediana",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "空ではない数",
"calcResultPercentEmpty": "空のパーセント",
"calcResultPercentNotEmpty": "空ではないパーセント",
"calcResultPercentUniqueValues": "ユニーク値の割合",
"calcResultSum": "合計値",
"calcResultAverage": "平均値",
"calcResultMedian": "中央値",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "空ではない数",
"calcOperatorPercentEmpty": "空のパーセント",
"calcOperatorPercentNotEmpty": "空ではないパーセント",
"calcOperatorPercentUniqueValues": "ユニーク値の割合",
"calcOperatorSum": "合計値",
"calcOperatorAverage": "平均値",
"calcOperatorMedian": "中央値",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "NIE PUSTY",
"calcResultPercentEmpty": "PUSTE",
"calcResultPercentNotEmpty": "NIE PUSTE",
"calcResultPercentUniqueValues": "Procent unikalnych wartości",
"calcResultSum": "SUMA",
"calcResultAverage": "ŚREDNIA",
"calcResultMedian": "MEDIANA",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "Zlicz niepuste",
"calcOperatorPercentEmpty": "Procent pustych",
"calcOperatorPercentNotEmpty": "Procent niepustych",
"calcOperatorPercentUniqueValues": "Procent unikalnych wartości",
"calcOperatorSum": "Suma",
"calcOperatorAverage": "Średnia",
"calcOperatorMedian": "Mediana",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "НЕ ПУСТО",
"calcResultPercentEmpty": "ПУСТО",
"calcResultPercentNotEmpty": "НЕ ПУСТО",
"calcResultPercentUniqueValues": "Процент уникальных значений",
"calcResultSum": "СУММА",
"calcResultAverage": "СРЕДНЕЕ",
"calcResultMedian": "МЕДИАНА",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "Подсчитать непустые",
"calcOperatorPercentEmpty": "Процент пустых",
"calcOperatorPercentNotEmpty": "Процент не пустых",
"calcOperatorPercentUniqueValues": "Процент уникальных значений",
"calcOperatorSum": "Сумма",
"calcOperatorAverage": "Среднее",
"calcOperatorMedian": "Медиана",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "已填寫",
"calcResultPercentEmpty": "未填寫佔比",
"calcResultPercentNotEmpty": "已填寫佔比",
"calcResultPercentUniqueValues": "唯一值佔比",
"calcResultSum": "求和",
"calcResultAverage": "平均值",
"calcResultMedian": "中位數",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "已填寫",
"calcOperatorPercentEmpty": "未填寫佔比",
"calcOperatorPercentNotEmpty": "已填寫佔比",
"calcOperatorPercentUniqueValues": "唯一值佔比",
"calcOperatorSum": "求和",
"calcOperatorAverage": "平均值",
"calcOperatorMedian": "中位數",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"calcResultCountNotEmpty": "已填写",
"calcResultPercentEmpty": "未填写占比",
"calcResultPercentNotEmpty": "已填写占比",
"calcResultPercentUniqueValues": "唯一值占比",
"calcResultSum": "求和",
"calcResultAverage": "平均值",
"calcResultMedian": "中位数",
Expand All @@ -256,6 +257,7 @@
"calcOperatorCountNotEmpty": "已填写",
"calcOperatorPercentEmpty": "未填写占比",
"calcOperatorPercentNotEmpty": "已填写占比",
"calcOperatorPercentUniqueValues": "唯一值占比",
"calcOperatorSum": "求和",
"calcOperatorAverage": "平均值",
"calcOperatorMedian": "中位数",
Expand Down
16 changes: 16 additions & 0 deletions app/src/protyle/render/av/calc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ export const openCalcMenu = async (protyle: IProtyle, calcElement: HTMLElement,
blockID,
target: calcElement
});
calcItem({
menu,
protyle,
colId,
avId,
oldOperator,
operator: "Percent unique values",
data: panelData?.data,
blockID,
target: calcElement
});
} else {
calcItem({
menu,
Expand Down Expand Up @@ -427,6 +438,9 @@ export const getCalcValue = (column: IAVColumn) => {
case "Percent not empty":
value = `<span>${resultCalc.formattedContent}</span>${window.siyuan.languages.calcResultPercentNotEmpty}`;
break;
case "Percent unique values":
value = `<span>${resultCalc.formattedContent}</span>${window.siyuan.languages.calcResultPercentUniqueValues}`;
break;
case "Sum":
value = `<span>${resultCalc.formattedContent}</span>${window.siyuan.languages.calcResultSum}`;
break;
Expand Down Expand Up @@ -486,6 +500,8 @@ export const getNameByOperator = (operator: string, isRollup: boolean) => {
return window.siyuan.languages.calcOperatorPercentEmpty;
case "Percent not empty":
return window.siyuan.languages.calcOperatorPercentNotEmpty;
case "Percent unique values":
return window.siyuan.languages.calcOperatorPercentUniqueValues;
case "Checked":
return window.siyuan.languages.checked;
case "Unchecked":
Expand Down
41 changes: 21 additions & 20 deletions kernel/av/calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,25 @@ type ColumnCalc struct {
type CalcOperator string

const (
CalcOperatorNone CalcOperator = ""
CalcOperatorCountAll CalcOperator = "Count all"
CalcOperatorCountValues CalcOperator = "Count values"
CalcOperatorCountUniqueValues CalcOperator = "Count unique values"
CalcOperatorCountEmpty CalcOperator = "Count empty"
CalcOperatorCountNotEmpty CalcOperator = "Count not empty"
CalcOperatorPercentEmpty CalcOperator = "Percent empty"
CalcOperatorPercentNotEmpty CalcOperator = "Percent not empty"
CalcOperatorSum CalcOperator = "Sum"
CalcOperatorAverage CalcOperator = "Average"
CalcOperatorMedian CalcOperator = "Median"
CalcOperatorMin CalcOperator = "Min"
CalcOperatorMax CalcOperator = "Max"
CalcOperatorRange CalcOperator = "Range"
CalcOperatorEarliest CalcOperator = "Earliest"
CalcOperatorLatest CalcOperator = "Latest"
CalcOperatorChecked CalcOperator = "Checked"
CalcOperatorUnchecked CalcOperator = "Unchecked"
CalcOperatorPercentChecked CalcOperator = "Percent checked"
CalcOperatorPercentUnchecked CalcOperator = "Percent unchecked"
CalcOperatorNone CalcOperator = ""
CalcOperatorCountAll CalcOperator = "Count all"
CalcOperatorCountValues CalcOperator = "Count values"
CalcOperatorCountUniqueValues CalcOperator = "Count unique values"
CalcOperatorCountEmpty CalcOperator = "Count empty"
CalcOperatorCountNotEmpty CalcOperator = "Count not empty"
CalcOperatorPercentEmpty CalcOperator = "Percent empty"
CalcOperatorPercentNotEmpty CalcOperator = "Percent not empty"
CalcOperatorPercentUniqueValues CalcOperator = "Percent unique values"
CalcOperatorSum CalcOperator = "Sum"
CalcOperatorAverage CalcOperator = "Average"
CalcOperatorMedian CalcOperator = "Median"
CalcOperatorMin CalcOperator = "Min"
CalcOperatorMax CalcOperator = "Max"
CalcOperatorRange CalcOperator = "Range"
CalcOperatorEarliest CalcOperator = "Earliest"
CalcOperatorLatest CalcOperator = "Latest"
CalcOperatorChecked CalcOperator = "Checked"
CalcOperatorUnchecked CalcOperator = "Unchecked"
CalcOperatorPercentChecked CalcOperator = "Percent checked"
CalcOperatorPercentUnchecked CalcOperator = "Percent unchecked"
)
Loading

0 comments on commit 1e28680

Please sign in to comment.