Zettelkasten Forum


[Plugin] ZK Stats in a table by month

edited November 19 in Plug-In Showcase

Yet another sample plugin. This one produces a note with a table much like the one below. It also puts the note in the system clipboard so it can be placed elsewhere.

Here it the GitHub link to the source woodenzen/zk-stats and here's a link to the release install zip Release v1.0 · woodenzen/zk-stats.

Post edited by ctietze on

Will Simpson
My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
kestrelcreek.com

Comments

  • Thanks. It worked fine, but some figures are strange, so I have a few questions:

    What is counted in the monthly breakdown?
    The Total Number of Notes in Zettelkasten corresponds to the number of markdown files (I find 5163 in Finder and the plugin indicates 5165, so the difference is only 2) but the total of the figures in the monthly breakdown table is just 771 (15% of the Total).

    Still in the monthly breakdown, do you count on the creation date or the modification date?

    "Proofing Oven" counts notes tagged "#proofing"?

    What does "Total Link Count" count? I believed it was the internal links ([[ ]]) but my test of confirmation did not work.

    And a suggestion: to add a line between "Monthly Breakdown:" and the table to allow it to be displayed as a table in Marked 2.

  • @APG said:
    Thanks. It worked fine, but some figures are strange, so I have a few questions:

    What is counted in the monthly breakdown?

    The plugin examines the files in the directory and examines the string of 12 digits. It then breaks down the string into year, month, and day, grouping on the months. Here is the code that breaks down the string. It sounds like the script is running into file names with unusual UUIDs.

    // Function to extract and count dates from filenames
    function countFilesByMonth(notes) {
      let counts = {};
      notes.forEach(note => {
        const match = note.filename.match(/\d{12}/);
        if (match) {
          const dateStr = match[0];
          const year = dateStr.slice(0, 4);
          const month = dateStr.slice(4, 6);
          const key = `${year}-${month}`;
          counts[key] = (counts[key] || 0) + 1;
        }
      });
      return counts;
    }
    

    The Total Number of Notes in Zettelkasten corresponds to the number of markdown files (I find 5163 in Finder, and the plugin indicates 5165, so the difference is only 2). Still, the total of the figures in the monthly breakdown table is just 771 (15% of the Total).

    Yes, there is something fishy about these different counts.
    In my case, 4123 was reported in the plugin, and 4132 by Finder. The reason is that I have 9 notes with no UUID in the file names.

    Still in the monthly breakdown, do you count on the creation date or the modification date?

    Neither. The date is formed from the UUID.

    "Proofing Oven" counts notes tagged "#proofing"?

    This is my personal inbox workflow and should be removed from the plugin. It is currently hardcoded. I've not seen a way to prompt for two variables. I could ask the user if they use an #inbox.

    What does "Total Link Count" count? I believed it was the internal links ([[ ]]) but my test of confirmation did not work.

    This is the regex that is used to count the links.
    /[ ,§]\[\[/g

    Any pair of '[' preceded by a space or a '§'. Thinking about this I need to change this so it captures links at the begging of a line also.

    This is a better regex. FIXED
    /(^|\s|§)\[\[/g

    And a suggestion: to add a line between "Monthly Breakdown:" and the table to allow it to be displayed as a table in Marked 2.

    Thanks for the tip about Marked 2. FIXED

    GitHub New Release v1.1 · woodenzen/zk-stats

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

  • Thanks for your answer, I believe I've understood the difference between the monthly table and the total: the table only counts file with an UUID, which in my case are a small minority as I rename all notes (those with an UUID should have been renamed or deleted).

    I've tested the new version and it worked fine, except a difficulty at install: I had to rename the file from com.will.stats-2.thearchiveplugin to com.will.stats.thearchiveplugin as the former was rejected by The Archive:

  • This has been a great interchange! It is the kind of feedback that I love and crave. Thank you for taking the time to install and try it out. I learn a few things.

    @APG said:
    Thanks for your answer, I believe I've understood the difference between the monthly table and the total: the table only counts file with an UUID, which in my case are a small minority as I rename all notes (those with an UUID should have been renamed or deleted).

    You are not using UUIDs in the filenames makes a good use case for using the created date to count and sort the files in The Archive. Not in my case because DropBox reset the created date on ½ of my files when I rebased my Mac at one point. Fortunately, I religiously use a UUID in the file name.

    I've tested the new version and it worked fine, except a difficulty at install: I had to rename the file from com.will.stats-2.thearchiveplugin to com.will.stats.thearchiveplugin as the former was rejected by The Archive.

    I've run into this when upgrading an already installed bundle via the distribution method. This is a system thing. If the zip unbundles in the same directory as it was previously used, the file will be renamed com.will.stats-2.thearchiveplugin and be rejected. Maybe there is something the @ctietze could do programmatically or something someone can suggest to overcome this.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

  • edited November 20

    I ran the ZK stats plug-in with success!

    My table is too wide to fit the narrow editor, though! 😅 Maybe you could produce multiple tables with ~8--10 years worth of columns per table?

    But the output looks good. It's almost a heat map:

    Zettelkasten Stats

    ★★★★★★★★★★★★★★★★★★
    Total Number of Notes in Zettelkasten: 9687
    Total Word Count: 1269821
    Average Word Count: 131.09
    Total Link Count: 4041
    Average Link Count: 0.42
    Total Notes in Proofing Oven: 0

    Monthly Breakdown:

    Month 0000 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
    January 0 0 6 4 12 61 71 75 25 37 35 70 28 65 37 22 37 113
    February 0 0 2 0 15 48 50 25 21 5 38 48 16 23 54 40 8 113
    March 0 0 3 6 14 30 28 26 38 11 22 55 29 20 47 49 59 115
    April 0 1 5 9 19 39 63 8 10 14 36 47 19 9 38 38 62 86
    May 0 0 6 6 21 78 67 13 21 12 42 30 26 24 72 74 51 27
    June 0 0 2 5 22 68 40 24 30 30 43 25 20 41 52 58 48 65
    July 0 6 0 13 29 98 56 52 21 43 101 18 32 31 58 53 49 47
    August 0 0 0 21 15 47 18 17 14 20 62 22 17 31 81 48 115 30
    September 0 2 11 27 11 33 49 19 30 25 48 41 33 12 28 51 48 7
    October 0 0 7 13 12 46 53 25 4 82 52 23 38 28 79 57 34 43
    November 0 0 5 24 27 75 31 45 15 100 84 25 24 109 49 44 91 19
    December 0 7 5 34 10 51 41 27 10 21 74 20 36 38 52 23 73 0

    Author at Zettelkasten.de • https://christiantietze.de/

  • edited November 20

    Thanks for suggesting producing tables 10 years at a time. They would fit better in an 80-column editor. Your output appears to be in a proportional font. Is that true?

    This may have been mentioned elsewhere, but I want to customize my theme so that tables use a fixed format and the body of the note can use a proportional font. I hate having to switch my fonts back and forth.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

  • Ok, I just couldn't leave well enough alone. A moment's worth of coding, and I have a solution. More time was spent creating a test branch in Git, then merging it and producing a new release than doing the actual change.

    Release Version 1.2 changed the table format, and it is now exactly 80 characters wide, fitting in The Archive's default editor window.

    Production Release v1.2 of ZK Stats

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

  • Good idea to rotate the table! Then the size is capped!

    This may have been mentioned elsewhere, but I want to customize my theme so that tables use a fixed format and the body of the note can use a proportional font. I hate having to switch my fonts back and forth.

    Yes I want this, too, but I didn't want to mess with the current themes and plug-ins. Will tackle this soon, finally!

    Author at Zettelkasten.de • https://christiantietze.de/

Sign In or Register to comment.