actual icon indicating copy to clipboard operation
actual copied to clipboard

[WIP] Custom Reports: save reports (*new SQL table creation*)

Open carkom opened this issue 1 year ago • 3 comments

WARNING: This PR includes a migration file to create a new "reports" table. Do not test this PR without first backing up your budget file.

Allows for saving custom Reports.

carkom avatar Feb 05 '24 23:02 carkom

Deploy Preview for actualbudget ready!

Name Link
Latest commit d2fb6e7523b8792f1eef3af1fda6ebd253bf5593
Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/65d622c7a1ff69000803b708
Deploy Preview https://deploy-preview-2335.demo.actualbudget.org/
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Feb 05 '24 23:02 netlify[bot]

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
10 4.45 MB → 4.46 MB (+6.48 kB) +0.14%
Changeset
File Δ Size
src/components/reports/reports/CustomReportListCards.tsx 🆕 +5.7 kB 0 B → 5.7 kB
src/components/reports/Overview.jsx 📈 +526 B (+35.95%) 1.43 kB → 1.94 kB
src/components/reports/SaveReport.tsx 📈 +460 B (+13.37%) 3.36 kB → 3.81 kB
src/components/reports/graphs/DonutGraph.tsx 📈 +165 B (+2.66%) 6.07 kB → 6.23 kB
src/components/reports/reports/CustomReport.jsx 📈 +74 B (+0.51%) 14.15 kB → 14.22 kB
src/components/reports/ChooseGraph.tsx 📈 +15 B (+0.41%) 3.61 kB → 3.62 kB
src/components/reports/util.ts 📈 +2 B (+0.25%) 798 B → 800 B
src/components/reports/graphs/StackedBarGraph.tsx 📈 +11 B (+0.21%) 5.08 kB → 5.09 kB
src/components/reports/spreadsheets/net-worth-spreadsheet.ts 📈 +2 B (+0.06%) 3.42 kB → 3.43 kB
src/components/reports/graphs/CashFlowGraph.tsx 📉 -4 B (-0.08%) 4.6 kB → 4.59 kB
src/components/reports/spreadsheets/filterHiddenItems.ts 📉 -5 B (-0.53%) 939 B → 934 B
src/components/reports/graphs/AreaGraph.tsx 📉 -140 B (-1.70%) 8.06 kB → 7.92 kB
src/components/reports/graphs/BarGraph.tsx 📉 -140 B (-1.93%) 7.1 kB → 6.96 kB
home/runner/work/actual/actual/packages/loot-core/src/client/data-hooks/reports.ts 📉 -168 B (-12.78%) 1.28 kB → 1.12 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
static/js/AppliedFilters.js 0 B → 20.35 kB (+20.35 kB) -

Removed

Asset File Size % Changed
static/js/MenuTooltip.js 20 kB → 0 B (-20 kB) -100%

Bigger

Asset File Size % Changed
static/js/ReportRouter.js 1.2 MB → 1.2 MB (+6.48 kB) +0.53%

Smaller

Asset File Size % Changed
static/js/wide.js 267.81 kB → 267.47 kB (-354 B) -0.13%

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/ButtonLink.js 379 B 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/narrow.js 79.85 kB 0%
static/js/BalanceTooltip.js 6.06 kB 0%
static/js/index.js 2.74 MB 0%

github-actions[bot] avatar Feb 05 '24 23:02 github-actions[bot]

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.2 MB → 1.2 MB (+74 B) +0.01%
Changeset
File Δ Size
packages/loot-core/src/server/aql/schema/index.ts 📈 +125 B (+0.89%) 13.73 kB → 13.86 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.2 MB → 1.2 MB (+74 B) +0.01%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

github-actions[bot] avatar Feb 05 '24 23:02 github-actions[bot]

@carkom I would love to test! Thank you for getting this to such an exciting point.

I have been trying to import my existing budget to give this a whirl. Unfortunately I get an error message when importing: "An unknown error occurred while importing. Please report this as a new issue on Github." Maybe this is because I am running the edge tag?

YES - that seemed to be it. I have been able to import a 24.1.0 file created under "latest"

Kidglove57 avatar Feb 06 '24 19:02 Kidglove57

@carkom I would love to test! Thank you for getting this to such an exciting point.

I have been trying to import my existing budget to give this a whirl. Unfortunately I get an error message when importing: "An unknown error occurred while importing. Please report this as a new issue on Github." Maybe this is because I am running the edge tag?

YES - that seemed to be it. I have been able to import a 24.1.0 file created under "latest"

Thanks for your excitement! I still have a few issues to iron out before it's ready for testing. I'll ping you when it's ready for a test. Cheers!

carkom avatar Feb 06 '24 19:02 carkom

Ah - that explains why I was not actually able to save a report! Thank you. It did create a second 'Custom Report" entry on the Reports screen. But just a generic one. Thanks

Kidglove57 avatar Feb 06 '24 19:02 Kidglove57

You need to change the timestamp on that migration. Importing doesn't work since the simplefin migrations have a newer time

youngcw avatar Feb 06 '24 22:02 youngcw

It doesn't seem like the reports are saving. If I create a test file then try to make a report it doesn't seem like anything happens other than the name now shows up in the save menu. If I leave the report and go back to the reports dash, nothing is there.

Also, the custom report shows up twice on the dash once its enabled.

youngcw avatar Feb 06 '24 22:02 youngcw

It doesn't seem like the reports are saving. If I create a test file then try to make a report it doesn't seem like anything happens other than the name now shows up in the save menu. If I leave the report and go back to the reports dash, nothing is there.

Also, the custom report shows up twice on the dash once its enabled.

Yea, I marked it as WIP and commented out the actual table creation until I could fix all the issues. Thanks for lookin out.

carkom avatar Feb 07 '24 22:02 carkom

Ah - that explains why I was not actually able to save a report! Thank you. It did create a second 'Custom Report" entry on the Reports screen. But just a generic one. Thanks

Yea, that second one was actually hard coded in due to a wonky merge.

It's all cleaned up now and should be useable. LMK!

carkom avatar Feb 07 '24 22:02 carkom

Ah! I'd just thought I couldn't import due to the migration part and I'd have to pull locally to test etc.

  • Have tested now, able to import just fine.
  • Just the one custom report card to start as per your comment.

Found a crashing bug:

  1. Open the default custom reports card
  2. Change type to a table report and save.
  3. Return to the reports page.
  4. Try to open the table report.

Tried saving as other chart types and opening them, no crash with them. No crash if I save a table report, change chart type, and revert. So only leaving and when loading from the card. Able to replicate using the test budget.

  • Reports page - index number in tool tip instead of month for the bar chart preview when in 'time' mode': image

  • Donut preview card mouse over, the labels are hard to read with the donut behind it and (leading? whatever) line. Not important TBH, just a function of the small scale.

As always, thanks for your work!

Sneaky, well not edit since I hadn't hit post yet, as I was going to test one other thing that suddenly came to mind, I started seeing these errors pop up (text from console).

image

SELECT custom_reports.id AS id, custom_reports.name AS name, custom_reports.start_date AS start_date, custom_reports.end_date AS end_date, custom_reports.date_static AS date_static, custom_reports.date_range AS date_range, custom_reports.mode AS mode, custom_reports.group_by AS group_by, custom_reports.balance_type AS balance_type, custom_reports.show_empty AS show_empty, custom_reports.show_offbudget AS show_offbudget, custom_reports.show_hidden AS show_hidden, custom_reports.show_uncategorized AS show_uncategorized, custom_reports.selected_categories AS selected_categories, custom_reports.graph_type AS graph_type, custom_reports.conditions AS conditions, custom_reports.conditions_op AS conditions_op, custom_reports.metadata AS metadata, custom_reports.interval AS interval, custom_reports.color_scheme AS color_scheme, custom_reports.tombstone AS tombstone FROM custom_reports
    
    WHERE 1 AND custom_reports.tombstone = 0   
    
  [kcab.worker.b440d04aeb5601e00806.js:16:407123](https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js)
[Exception] Error: database disk image is malformed
    handleError https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:1
    step https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:1
    aA https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:16
    cI https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:150
    cL https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:150
    sd https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:77
    sp https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:77
    sh https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:77
    sO https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:109
    query https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:250
    as https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:16
    ag https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js:16
[kcab.worker.b440d04aeb5601e00806.js:16:403629](https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js)
Error: database disk image is malformed 2 [kcab.worker.b440d04aeb5601e00806.js:1:8138](https://deploy-preview-2335.demo.actualbudget.org/kcab/kcab.worker.b440d04aeb5601e00806.js)

Also when trying to save a new report: ​ image

Went to close the budget file and it appears indefinite on this animation: image

I deleted budget files, but unable to re-import or create the test budget file again.

So naturally I changed browsers for my last check - able to save a custom report, export my budget, delete it from browser, then re-import and see the custom report present.

Will see if I can dig around and reproduce the above error tomorrow to get you some steps to reproduce.

Teprifer avatar Feb 08 '24 07:02 Teprifer

Ah! I had a thought so I wanted to test something and along the way I came across some more info for the table crash. If I click the heading of the card - the report opens with no crash. It differs on crash vs no crash depending on which area I click on.

/sneaky edit to add the show error text I forgot to include/

TypeError: Cannot read properties of null (reading 'map') at eae (https://deploy-preview-2335.demo.actualbudget.org/static/js/ReportRouter.oVG5-GMm.chunk.js:139:31557) at Jx (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:49:19539) at zI (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:51:44045) at NI (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:51:39777) at pL (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:51:39705) at _h (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:51:39557) at _0 (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:51:35921) at $I (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:51:34870) at E (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:36:1544) at MessagePort.R (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.9C6Mx0Rp.js:36:1903)

Console(from edge)

image

Teprifer avatar Feb 08 '24 07:02 Teprifer

As others have commented, saving a report works just great! I have saved a data table based Income and Expense Report for 2023 and another for 2024. These appear correctly on the Reports page. However, as I'm sure you are already aware, I cannot access them again without getting "an irrecoverable error in the UI".

This error occurs whether I use my own file or the test file.

EDIT: I need to clarify that this UI error ONLY occurs for me with saved Data Table Reports. Donut, Bar and Area Graphs reopen fine after saving. I'm using safari on a Mac.

Kidglove57 avatar Feb 08 '24 10:02 Kidglove57

Thanks everyone. I've fixed the tableGraph recall crash. Please have a look. I'll have a look at the other visual issues pointed out above later tonight.

carkom avatar Feb 08 '24 17:02 carkom

the saved reports have a white border around their dashboard cards where the other cards dont

The table card is really tight and only fits one category of data. Maybe that one should be setup to only show a selection of totals/averages or something.

youngcw avatar Feb 08 '24 18:02 youngcw

the saved reports have a white border around their dashboard cards where the other cards dont

The table card is really tight and only fits one category of data. Maybe that one should be setup to only show a selection of totals/averages or something.

I'll fix the border. I have an uncommitted change to use smaller text for compact tables. Stay tuned.

carkom avatar Feb 08 '24 18:02 carkom

the saved reports have a white border around their dashboard cards where the other cards dont The table card is really tight and only fits one category of data. Maybe that one should be setup to only show a selection of totals/averages or something.

I'll fix the border. I have an uncommitted change to use smaller text for compact tables. Stay tuned.

I think the padding looks pretty good, I was thinking of lodging an enhancement request to add the same padding to the default cards.

Teprifer avatar Feb 08 '24 18:02 Teprifer

I don't dislike the border, it just makes the space for data really tight. I would be ok if the cards were bigger and maintained the border.

youngcw avatar Feb 08 '24 18:02 youngcw

Okay, the tableGraph cards should be more visible. LMK what you think!

carkom avatar Feb 08 '24 20:02 carkom

Okay, the tableGraph cards should be more visible. LMK what you think!

Nice. That looks pretty good. I tested with a whole year of data. It cant show everything but enough to be useful

youngcw avatar Feb 08 '24 20:02 youngcw

Okay, the tableGraph cards should be more visible. LMK what you think!

Nice. That looks pretty good. I tested with a whole year of data. It cant show everything but enough to be useful

Ahh, cool, thanks. Yea I'd say as long as it's good enough to get the idea. 👍

carkom avatar Feb 08 '24 21:02 carkom

I was able to re-import my budget after telling Firefox to delete all data for actualbudget.org

Table chart preview changes look good. Confirming no table preview crashing. Confirming bar chart tool tips fixed.

With the tweaks to the preview cards, it gives a real dashboard like feel which is pretty cool.

Not sure if blind yesterday(it wasn't a good day), but I spotted the options to rename(disabled), and delete reports from the preview screen. A nice touch. :)

  • Minor visual: I like what you did with the donut tooltips in preview mode, although it has a small niggle - the text is a bit cut off at the bottom for letters that have a bit that goes 'below the line': image The graph itself sits a bit 'low' vertically within the card and it looks like this is true for viewing the full size version as well. Potentially scope to move it upwards in both views and creating room for the text in the preview as a result? image

  • Visual: Area chart previews are using the same color for deposit and payment, whereas payment and negative net is red when viewing the full graph, other graph types retain their colours: image

I'll be honest, this is truly awesome, I'm only finding small stuff like this because I want to see if I can reproduce the issue I had last night and are poking at it oddly but chances are you probably fixed whatever caused it, or it was due to the wind changing direction. Thankfully, no one can see ones typos in screenshots when you can rename a report so easily. 😆

Apologies for not thinking of this earlier in the other PR, so uh, thoughts on replacing the big "Custom Reports" in the top left with an equally sized version of the right save/revert/delete menu you've added on the right? Removes a the 'custom report' heading on every report in favour of the title entered by the user.

Mock up: image

Teprifer avatar Feb 09 '24 07:02 Teprifer

Adding this here as I can't reproduce it in the latest release so it might not be related to # 2091 - tool tips aren't always going away when mousing out of a preview card, so one can collect a number of tool tips.

Teprifer avatar Feb 09 '24 07:02 Teprifer

Thanks everyone. I've fixed the tableGraph recall crash. Please have a look. I'll have a look at the other visual issues pointed out above later tonight.

Sorry for delay - all working great now. Thank you!

Kidglove57 avatar Feb 09 '24 08:02 Kidglove57

Do you have plans on a way to sort the reports on the dashboard?

youngcw avatar Feb 11 '24 21:02 youngcw

The ultimate goal is to use drag and drop so users can sort as they'd like. This PR is just alphabetical by name.

carkom avatar Feb 12 '24 00:02 carkom

Is there somewhere in the DB table to save the sort data? Is it in the conditions field?

youngcw avatar Feb 12 '24 00:02 youngcw

Currently there's no data being saved for sort order. It's just hard coded as alphabetical. Previously mentioned here. Happy to chat further about it.

https://github.com/actualbudget/actual/pull/1924#discussion_r1398212637

carkom avatar Feb 12 '24 07:02 carkom

  • Filters applied with the funnel icon are not being saved, don't know if it's expected
  • Tooltips menu with many entries in time mode bar graph might not show entirely Screenshot 2024-02-12 092342
  • Saving this report (bar graph, split by month, type net) and opening it crashes the app Screenshot 2024-02-12 092811

TypeError: Cannot read properties of undefined (reading 'arr') at Ky (https://deploy-preview-2335.demo.actualbudget.org/static/js/ReportRouter.P1YzQ9Vw.chunk.js:113:12961) at qx (https://deploy-preview-2335.demo.actualbudget.org/static/js/ReportRouter.P1YzQ9Vw.chunk.js:113:14951) at T1 (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.fMTSsfnj.js:56:19539) at gD (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.fMTSsfnj.js:58:44045) at fD (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.fMTSsfnj.js:58:39777) at QL (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.fMTSsfnj.js:58:39705) at Qh (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.fMTSsfnj.js:58:39557) at tv (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.fMTSsfnj.js:58:35921) at uD (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.fMTSsfnj.js:58:34870) at E (https://deploy-preview-2335.demo.actualbudget.org/static/js/index.fMTSsfnj.js:43:1544)

Redbox3070 avatar Feb 12 '24 08:02 Redbox3070

If there's no other feedback I'd say this one is ready for review.

carkom avatar Feb 13 '24 19:02 carkom