Skip to content

Commit

Permalink
Some fixes to analytics and operations results
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierstoval committed Apr 8, 2024
1 parent 24d2301 commit d2eba71
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs;
use std::path::PathBuf;
use tauri::api::path::home_dir;

pub(crate) const NUMBER_PER_PAGE: u16 = 10;
pub(crate) const NUMBER_PER_PAGE: u16 = 20;

pub(crate) fn compotes_dir() -> PathBuf {
let compotes_dir = home_dir()
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/entities/tag_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub(crate) fn find_all(conn: &Connection) -> Vec<TagRule> {
WHERE tag_rule_id = tag_rules.id
) AS tags_ids
FROM tag_rules
ORDER BY length(matching_pattern) DESC
",
)
.expect("Could not fetch tag_rules");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
});
}
async function selectFilter(event) {
const name = event.target.value;
async function selectFilter(name: string|null) {
selected_filter = name || null;
if (!name) {
await clearFilters();
Expand Down Expand Up @@ -150,8 +149,7 @@
name="filters_select"
id="filters_select"
class="form-control ms-auto"
bind:value={selected_filter}
on:change={selectFilter}
on:change={(e) => selectFilter(e.value)}
>
<option value="">- Select a filter -</option>
{#each saved_filters as filter}
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/Navigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
syncing = true;
const res = await OperationsSynchronizer.sync();
console.info({res});
message(res.isOk() ? res.unwrap() : res.unwrapErr(), res.isOk() ? ToastType.success : ToastType.error);
syncing = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/operation_graphs/YearMonthTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class YearMonthTags extends AbstractOperationGraph {
full_series[year].tags[tag_name].months[month] = 0;
}

full_series[year].tags[tag_name].months[month] += operation.amount;
full_series[year].tags[tag_name].months[month] += Number(operation.amount);
}
}

Expand Down
17 changes: 5 additions & 12 deletions src/routes/analytics/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
async function changeFilter(event: CustomEvent) {
const selected_filter: SavedFilter | null = event.detail;
console.info('changed filter', selected_filter);
if (!selected_filter) {
operations = [];
return;
Expand Down Expand Up @@ -101,8 +99,6 @@
`Invalid graph type "${current_graph_type}" (value type found: "${type}").`
);
}
console.info('chart_data', chart_data);
}
</script>

Expand Down Expand Up @@ -172,16 +168,16 @@
{#if chart_data?.datasets}
<h2>Data:</h2>

<table class="table table-bordered table-striped table-hover">
<table class="table table-sm">
<thead class="thead-dark">
<tr>
<td>&nbsp;</td>
{#each (chart_data?.labels||[]) as label}
<th>{label}</th>
{/each}
<th>#Average/Mean</th>
<th>#Median</th>
<th>#Total</th>
<th># Average/Mean</th>
<th># Median</th>
<th># Total</th>
</tr>
</thead>
<tbody>
Expand All @@ -190,10 +186,7 @@
<td>{dataset.label}</td>
{#each dataset.data as data}
<td style="text-align: right;">
<span data-toggle="tooltip" data-placement="top" title="{data}">
{new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(data).toString()}
</span>

{new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(data).toString()}
</td>
{/each}
<td>{new Intl.NumberFormat('fr-FR', {style: 'currency', currency: 'EUR'}).format(dataset.data.reduce((a, b) => a + b, 0) / dataset.data.length).toString()}</td>
Expand Down

0 comments on commit d2eba71

Please sign in to comment.