franciskafieh / obsidian-list-modified

🪨 The advanced and adaptive changelog for Obsidian. Links all modified files meeting certain criteria to a timed (daily, weekly, monthly) note.
MIT License
85 stars 7 forks source link

[FR] Track file size changes #62

Closed danrthompson closed 8 months ago

danrthompson commented 1 year ago

One absolutely amazing feature would be to make it possible to see how large of a change was made to each file.

So let's say I create file1, modify file2 and file3, and delete file4. Let's say that file1 was created with 300 characters, file2 went from 500 to 1000 characters, file3 went from 400 to 250 characters, and file4 had 200 characters before being deleted (I'm using characters because I know it's straightforward to get the absolute size of the file, and more challenging to get the number of words, but words would work equally well).

In this case, it would be awesome to get the following info:

Ideally, this would be displayable in a table, but that's not a big deal. But the data would be fantastic.

This would necessitate maintaining a cache of the starting file manifest, including the existing files and their file sizes at the start of a given day. That way you would be able to figure out which files were created or deleted vs being modified. And, of course, the sizes would be necessary to calculate the changes on that front.

I don't think this would be trivial at all, but I also don't think it would be a massive amount of work.

In particular, there is one other plugin that has implemented a lot of this work (although they still do not provide the functionality I'm asking for): https://github.com/dhruvik7/obsidian-daily-stats.

So it might be possible to use some of the code from that plugin to build the cache.

Right now, I'm writing a fork of https://github.com/dhruvik7/obsidian-daily-stats that will store the caches for more than one day (right now it only tracks the size changes for the current day - not for the past). Then I'm going to see if I can implement something like what I'm talking about.

I have a ton of software engineering experience, but none with writing Obsidian plugins and pretty little with JS (mostly work in Python and used to use C++). But I think I can get this done if I make the time commitment.

I mention all of this to say that, if you want to implement this yourself, that would be absolutely amazing. If not, I may be able to add some code to the daily stats plugin that would make it easier for you to port over. Or possibly, if I have enough time, I might be able to help you implement this functionality.

Anyway, let me know what you think and if you're interested in this idea.

Thanks very much for your work on this awesome plugin - I really appreciate it!

Dan

franciskafieh commented 1 year ago

Let me know once you're done working on your fork and I'll take a look. If it is easy to consistently track changed words/characters without too much overhead (because some people have their list "interval" set low), I would definitely consider implementing it after I re-write the plugin for 2.1. I would honestly feel guilty to allow people to submit PRs until then, since the code is a mess :sweat_smile: just kinda wrote it to ship ASAP, but now it's getting hard to maintain

franciskafieh commented 1 year ago

For anyone else: please like the original comment if you would also like this feature implemented

danrthompson commented 1 year ago

@franciskafieh I can't guarantee I'll get around to this anytime soon, just because I haven't made an Obsidian plugin before and my Javascript experience is limited, so the amount of time it would take to implement this merely for myself might not be worth the value that this modified plugin would add.

But if I do get to it, I'll let you know.

I can confirm that the changes needed to implement this in the Daily Stats plugin are pretty minimal. They already create a daily index of the starting and ending size of each file modified that day. So if you want to take a look at that plugin's source code I think that would give you basically 80% of the idea of how it would be implemented/what kind of overhead that functionality would add

danrthompson commented 1 year ago

Fyi, I created my own very simple plugin that implements this. It's for personal use so it is far from robust, but you can take a look at it if you want, and you're of course welcome to borrow any of the code if it's useful. Probably will not be though given that I took a pretty simplistic approach to implementing it. https://github.com/danrthompson/obsidian-file-modification-stats

franciskafieh commented 8 months ago

For now, this will not be implemented as it falls outside of my current focus. If anyone still wants this implemented, feel free to re-open. It will probably only be implemented with a PR, though