Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Export command #286

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

yqs112358
Copy link

@yqs112358 yqs112358 commented Aug 5, 2024

New features

  • Add /ledger export <params> to export specific actions as CSV file
    • Add class DataExporter(searchParams, exportAdapter) to export actions
    • Add AbstructExportAdapter -> CsvExportAdapter, allow to add more other export formats in future
  • Add configurations in ledger.toml
  • Add docs with exported file example and translations

Other Small Changes

  • Fix: remove unnecessary ServerCommandSource param in XXActionType.getObjectMessage
  • Change: rename MessageUtils.instantToText to MessageUtils.instantTimeToDiffText to avoid name conflicts with new added functions
  • Change: add param pageSize in Transaction.selectActionsSearch to allow querying with custom page size (used by export)

Example

Export to ./world/data/ledger-export-<time>.csv in default.
Exported CSV table looks like below:

Time Source Action Object X Y Z World Extra
2024/8/5 13:36 X1aoSa added 64 Cobblestone -19 62 121 minecraft:overworld {count:64,id:"minecraft:cobblestone"}
2024/8/5 13:36 X1aoSa picked up 1 Red Shulker Box -15 65 119 minecraft:overworld {components:{"minecraft:container":[{…
2024/8/5 13:36 X1aoSa broke Red Shulker Box -15 65 120 minecraft:overworld {Items:[{Slot:1b,count:64,id:"minecraft:…
2024/8/5 13:36 X1aoSa removed 64 Cobblestone -15 65 120 minecraft:overworld {count:64,id:"minecraft:cobblestone"}
2024/8/5 13:36 X1aoSa removed 64 Cobblestone -15 65 120 minecraft:overworld {count:64,id:"minecraft:cobblestone"}
2024/8/5 13:36 X1aoSa placed Red Shulker Box -15 65 120 minecraft:overworld {Items:[{Slot:0b,count:64,id:"minecraft:…
2024/8/5 13:36 X1aoSa picked up 1 White Shulker Box -16 65 121 minecraft:overworld {components:{"minecraft:container":[…
2024/8/5 13:36 X1aoSa broke White Shulker Box -16 65 120 minecraft:overworld {Items:[{Slot:0b,count:64,id:"minecraft:…
2024/8/5 13:36 X1aoSa placed White Shulker Box -16 65 120 minecraft:overworld {Items:[{Slot:0b,count:64,id:"minecraft:rail...
2024/8/5 13:35 X1aoSa removed 64 Smooth Stone -17 64 104 minecraft:overworld {count:64,id:"minecraft:smooth_stone"}
2024/8/5 13:35 X1aoSa removed 64 Smooth Stone -17 64 104 minecraft:overworld {count:64,id:"minecraft:smooth_stone"}
2024/8/5 13:35 X1aoSa removed 2 Smooth Stone -17 64 104 minecraft:overworld {count:2,id:"minecraft:smooth_stone"}
2024/8/5 13:35 X1aoSa removed 11 Smooth Stone -17 64 104 minecraft:overworld {count:11,id:"minecraft:smooth_stone"}
2024/8/5 13:35 X1aoSa added 64 Cobblestone -19 62 121 minecraft:overworld {count:64,id:"minecraft:cobblestone"}
2024/8/5 13:34 X1aoSa changed Lever -24 65 119 minecraft:overworld
2024/8/5 13:34 X1aoSa changed Lever -24 65 119 minecraft:overworld
2024/8/5 13:34 @lava killed Bat -9 -55 152 minecraft:overworld {AbsorptionAmount:0.0f,Air:300s,…
2024/8/5 13:34 @fall killed Zombified Piglin 36 188 98 minecraft:the_nether {AbsorptionAmount:0.0f,Air:300s,…
2024/8/5 13:34 @fall killed Zombified Piglin 35 188 98 minecraft:the_nether {AbsorptionAmount:0.0f,Air:300s,…
2024/8/5 13:34 X1aoSa killed Magma Cube -14 65 129 minecraft:overworld {AbsorptionAmount:0.0f,Air:300s,…
2024/8/5 13:34 X1aoSa broke Sunflower -14 65 128 minecraft:overworld
2024/8/5 13:34 @Gravity broke Sunflower -14 66 128 minecraft:overworld

@zly2006
Copy link

zly2006 commented Oct 6, 2024

afaik most databases support exporting .sql files, why is this PR better? I found there is no way to import the data back. (I am reading #283)

@yqs112358
Copy link
Author

yqs112358 commented Oct 6, 2024

afaik most databases support exporting .sql files, why is this PR better? I found there is no way to import the data back. (I am reading #283)

It would be nice if there is a common way to export a .sql, which has a similar effect as this PR. The problem is that when using sqlite backend no such builtin export function is available🤔

Or, maybe can use sqlite CLI to do so? But would it cause problems if it reads and writes at the same time with ledger on the sqlite db?

@zly2006
Copy link

zly2006 commented Oct 6, 2024

It would be nice if there is a common way to export a .sql, which has a similar effect as this PR. The problem is that when using sqlite backend no such builtin export function is available🤔

Or, maybe can use sqlite CLI to do so? But would it cause problems if it reads and writes at the same time with ledger on the sqlite db?

sqlite cli can export .sql but yes, it does not support reading and writing at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants