pyrochlore / obsidian-tracker

A plugin tracks occurrences and numbers in your notes
MIT License
1.35k stars 231 forks source link

Is there a way to have streaks that only count weekdays? #250

Open gordonrobb opened 1 year ago

gordonrobb commented 1 year ago

I am currently tracking a few things and love the 'current streak' thing. I'm use it for all the habits I'm tracking along with a calander view.

One or two of my habits are work related so I'm only doing them on a weekday.

Is there a way to have the streak only count weekdays? or omit certain days of the week? I can add that I've done them on the weekend, but it put the total number of days out by 2 every week obviously.

GovSat1 commented 1 year ago

This plugin dev is MIA. However I don't think this would be overly complex to implement. It looks like the streak calculation functions are in expr.ts as maxStreak*

I think the easiest option would be that only an explicitly false checkbox breaks the streak (so to "skip" a day, leave an indeterminate checkbox). When using the calendar it would be nice to have a "greyed" circle out color or similar as well.

gordonrobb commented 1 year ago

This plugin dev is MIA. However I don't think this would be overly complex to implement. It looks like the streak calculation functions are in expr.ts as maxStreak*

I think the easiest option would be that only an explicitly false checkbox breaks the streak (so to "skip" a day, leave an indeterminate checkbox). When using the calendar it would be nice to have a "greyed" circle out color or similar as well.

OK, so in the frontmatter I have the field (sales: for example) and if I do sales that day, I put a 1 in it, and if I don't, I leave it blank. Are you saying that if I put something other than 1 in, but not blank, it would keep the streak, but not increase the number of days (which is what I want)

gordonrobb commented 1 year ago

I've just tried putting something other than 1 or leaving blank. If I put any number at all, it counts it as done, and adds it to streak. If I put any letter or word, it counts it as not done, and doesn't add it to streak. :(

GovSat1 commented 1 year ago

I've just tried putting something other than 1 or leaving blank. If I put any number at all, it counts it as done, and adds it to streak. If I put any letter or word, it counts it as not done, and doesn't add it to streak. :(

No I'm just proposing a possible solution to add to the plugin. It hasn't been updated in 2 years. You might want to monitor this repo: https://github.com/lazyguru/obsidian-tracker as @lazyguru has merged all of the open PRs. If I have time at some point to look into adding this feature I will submit a PR there.

gordonrobb commented 1 year ago

I've just tried putting something other than 1 or leaving blank. If I put any number at all, it counts it as done, and adds it to streak. If I put any letter or word, it counts it as not done, and doesn't add it to streak. :(

No I'm just proposing a possible solution to add to the plugin. It hasn't been updated in 2 years. You might want to monitor this repo: https://github.com/lazyguru/obsidian-tracker as @lazyguru has merged all of the open PRs. If I have time at some point to look into adding this feature I will submit a PR there.

Thanks. I hadn't realised there hadn't been updates in a while. Do you know of any more current Plugin that does a similar thing to Tracker?

lazyguru commented 1 year ago

@gordonrobb I'm doing my best to keep my fork updated and I'll gladly accept pull requests there or here (I'll merge them over on my fork as I don't have write access here). As already said I've merged most of the open PRs here already in my fork (there is one where there was some feedback provided and comments made it sound like maybe it wasn't the best way to implement the feature). If there is enough demand I can reach out to get my fork listed as an installable plugin replacing this one. Otherwise you can either install mine manually or you should be able to use BRAT

gordonrobb commented 1 year ago

@gordonrobb I'm doing my best to keep my fork updated and I'll gladly accept pull requests there or here (I'll merge them over on my fork as I don't have write access here). As already said I've merged most of the open PRs here already in my fork (there is one where there was some feedback provided and comments made it sound like maybe it wasn't the best way to implement the feature). If there is enough demand I can reach out to get my fork listed as an installable plugin replacing this one. Otherwise you can either install mine manually or you should be able to use BRAT

It's at times like this I realise how little I know about anything 😂. Fork?

GovSat1 commented 1 year ago

@gordonrobb I'm doing my best to keep my fork updated and I'll gladly accept pull requests there or here (I'll merge them over on my fork as I don't have write access here). As already said I've merged most of the open PRs here already in my fork (there is one where there was some feedback provided and comments made it sound like maybe it wasn't the best way to implement the feature). If there is enough demand I can reach out to get my fork listed as an installable plugin replacing this one. Otherwise you can either install mine manually or you should be able to use BRAT

Considering this is a fairly popular plugin and there isn't a suitable replacement as of right now, it would make sense to get your fork listed (or anyone willing to adopt & maintain). I don't really have the bandwidth for it at the moment, nor a ton of JS dev experience (enough to get by..). Some of the dependencies do need updating.

Didn't mean to derail this FR but obviously we will not be getting any new features added to this repo..

lazyguru commented 1 year ago

@gordonrobb I'm doing my best to keep my fork updated and I'll gladly accept pull requests there or here (I'll merge them over on my fork as I don't have write access here). As already said I've merged most of the open PRs here already in my fork (there is one where there was some feedback provided and comments made it sound like maybe it wasn't the best way to implement the feature). If there is enough demand I can reach out to get my fork listed as an installable plugin replacing this one. Otherwise you can either install mine manually or you should be able to use BRAT

It's at times like this I realise how little I know about anything 😂. Fork?

No worries :) You can go to https://github.com/lazyguru/obsidian-tracker to see my "copy" (eg fork) of this repository

lazyguru commented 1 year ago

@gordonrobb I'm doing my best to keep my fork updated and I'll gladly accept pull requests there or here (I'll merge them over on my fork as I don't have write access here). As already said I've merged most of the open PRs here already in my fork (there is one where there was some feedback provided and comments made it sound like maybe it wasn't the best way to implement the feature). If there is enough demand I can reach out to get my fork listed as an installable plugin replacing this one. Otherwise you can either install mine manually or you should be able to use BRAT

Considering this is a fairly popular plugin and there isn't a suitable replacement as of right now, it would make sense to get your fork listed (or anyone willing to adopt & maintain). I don't really have the bandwidth for it at the moment, nor a ton of JS dev experience (enough to get by..). Some of the dependencies do need updating.

Didn't mean to derail this FR but obviously we will not be getting any new features added to this repo..

Fair enough. And this plugin does get a bit of activity so it makes sense to have the one listed be maintained. I'll work on updating the README on my copy a bit more to call out that it is a maintained version of this repo and make sure to call out the original author. Then I'll open a request to have them change the plugin to point at my repo.

lazyguru commented 1 year ago

Hey all, I now have write access here and will be merging PRs and getting releases out within the next few days

lazyguru commented 1 year ago

If I have time at some point to look into adding this feature I will submit a PR there.

@GovSat1 please consider opening a PR here. Now that I have write access here I can review any PRs and create releases (I've already done one release and will do another in the next day or two)

GovSat1 commented 11 months ago

An alternative for those needing this now may be to use text/regex matching instead of frontmatter, depending on your use case.

In this example, for a checkbox, boolean true or null is considered valid and thus continues the streak. False would break the streak.

searchType: text
searchTarget: '^run:(\strue|\s|)$'
folder: log
datasetName: Run 🏃
startDate: 2023-01-01
endDate: 0d
month:
  mode: circle
  startWeekOn: 'Mon'

A configurable parameter would obviously be easier. My initial attempt worked but resulted in regressions elsewhere - I will dig into the code more when I have time. Ideally there would be some way to identify a "skipped" day on the calendar as well.

lazyguru commented 11 months ago

There is a fillGap that can be used with line:, I have not checked if it works with calendar or not as well

gordonrobb commented 11 months ago

An alternative for those needing this now may be to use text/regex matching instead of frontmatter, depending on your use case.

In this example, for a checkbox, boolean true or null is considered valid and thus continues the streak. False would break the streak.

searchType: text
searchTarget: '^run:(\strue|\s|)$'
folder: log
datasetName: Run 🏃
startDate: 2023-01-01
endDate: 0d
month:
  mode: circle
  startWeekOn: 'Mon'

A configurable parameter would obviously be easier. My initial attempt worked but resulted in regressions elsewhere - I will dig into the code more when I have time. Ideally there would be some way to identify a "skipped" day on the calendar as well.

Oh, I'll give this a try. Does this keep the streak going, but not add it to the total? (Which is ideally what I'm looking for).