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 option to pick Count period #31

Closed
olfek opened this issue Oct 20, 2022 · 20 comments · Fixed by #36
Closed

Add option to pick Count period #31

olfek opened this issue Oct 20, 2022 · 20 comments · Fixed by #36
Labels
enhancement New feature or request question Further information is requested
Milestone

Comments

@olfek
Copy link
Contributor

olfek commented Oct 20, 2022

Agreed to add option to pick period for counter: All time, This month, This week, Today

Note: Previous discussion started on how to reset the count (counter) but that won't be necessary.


Should counter persist between browsing sessions?

Especially considering there is no way to reset the counter.

🤔

@penge
Copy link
Owner

penge commented Oct 20, 2022

Hi @olfek

Counter is reset for a specific rule (let's say youtube.com) when you remove the rule from the blocked list AND then at any time after visit any website (let it be blocked or allowed). The reason for this implementation is that any changes in Options, including changes in blocked list, are saved automatically, and so counter shouldn't be reset immediately as you type the rules, otherwise even a slight change like removing a letter from youtube.com and then adding it back, would cause a reset of its counter.

But to be honest, I was a bit hesitant to add the Counter feature as it introduces a bit of gamification and replaces one addiction (of visiting a website) with another (how many blocked I have today?). I think Counter is not an essential information and doesn't change the fact I tried to access something I shouldn't. Doesn't matter if it was 10x or 100x. Maybe better if I don't know this information. Shall we remove the feature?

@penge penge added the question Further information is requested label Oct 20, 2022
@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

I would suggest adding a setting to enable/disable the counter rather than removing it completely. Someone might find it to be useful.

If an enable/disable setting is added, I'd recommend having it enabled by default so new users can see the extension in all its glory.

@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

Counter is reset for a specific rule (let's say youtube.com) when you remove the rule from the blocked list AND then at any time after visit any website (let it be blocked or allowed). The reason for this implementation is that any changes in Options, including changes in blocked list, are saved automatically, and so counter shouldn't be reset immediately as you type the rules, otherwise even a slight change like removing a letter from youtube.com and then adding it back, would cause a reset of its counter.

Yep this makes a lot of sense honestly, a counter since the rule was added. Besides, the counter would be even more useless if it reset on every new session, as it would be hiding our level of procrastination and unproductivity 😁

I could start a new session several times in one day so the counter wouldn't be very useful then.

@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

But, consider this example.

Suppose its been 2 months since I added a block rule.

The first month, I was visiting the blocked site a lot. Then the second month I wasn't visiting it very much.

It would be nice for the counter to show this improvement in a time range of my choice.

@penge
Copy link
Owner

penge commented Oct 20, 2022

...would be hiding our level of procrastination and unproductivity 😁

Exactly 😄

It would be nice for the counter to show this improvement in a time range of my choice.

We already save counter information as timestamps, so it's ready to show chart over time 😅

Maybe we could even add a highscore 🤣

If an enable/disable setting is added, I'd recommend having it enabled by default so new users can see the extension in all its glory.

This is quite easy to add. I was thinking about it. Probably best way to satisfy both parties?

@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

This is quite easy to add. I was thinking about it. Probably best way to satisfy both parties?

Sounds good but the enable/disable setting for the counter would be a new issue.

This issue is about when/if and under what circumstances the counter should be reset.

We already save counter information as timestamps, so it's ready to show chart over time 😅

Maybe we could even add a highscore 🤣

lol, to begin with, I think we should keep it simple. For me personally, I would want the counter to reset daily, but someone else might want the counter to reset weekly or monthly or never.

@penge
Copy link
Owner

penge commented Oct 20, 2022

Sounds good but the enable/disable setting for the counter would be a new issue.

Agreed.

lol, to begin with, I think we should keep it simple.

I think the same. I actually think no counter is needed at all. It doesn't bring me value to know my blocked stats. It's not a game.

@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

For me it has actually been useful, I can sometimes waste a lot of time on YouTube, the other day I involuntarily visited YouTube and saw the blocked screen with a block count of 30+, it made me re-evaluate my life choices haha 😅

Seeing the number so high reaffirmed my commitment to avoiding YouTube.

The counter makes the user feel guilty, makes them realise they have a problem, this is the counters purpose. Therefore this counter feature makes this extension more effective at combating procrastination, unproductivity and website addictions (YouTube in my case 😅)

@penge
Copy link
Owner

penge commented Oct 20, 2022

Tell me about it 😄 I don't want to see my YouTube counter because that number is just horrible 😄

Soooo. I think we can agree how resetting of counter works is as we need it to be. And can create a new issue to add option to enable show counter, by default shown or not shown?

@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

create a new issue to add option to enable show counter, by default shown or not shown?

by default - shown (allow new users to taste all the features)

and yep, create a new issue 👍

I think we can agree how resetting of counter works is as we need it to be.

Not for me unfortunately, I would like a daily reset.

@penge
Copy link
Owner

penge commented Oct 20, 2022

We don't need to reset anything 😉

We can just add a new dropdown to Options, where you would pick the era (filter, a view) for the displayed count: All time, This month, This week, Today.

How that sounds? If you agree, feel free to create a new issue.

@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

Yep that sounds perfect. Lets just use this issue.

@penge penge added the enhancement New feature or request label Oct 20, 2022
@penge penge added this to the 3.1 milestone Oct 20, 2022
@penge penge changed the title Should counter persist between browsing sessions? Add option to pick Count period Oct 20, 2022
@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

What would the performance implications be though, if I've been using the extension for 365 days, and I only want the count for today, the code will need to process all blocks that have occurred in the last 365 days to find the block count for today.

@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

pseudocode

FOR EACH block IN blockHistory
    IF block.date == today
        blockCount++

would it look something like this?

@olfek
Copy link
Contributor Author

olfek commented Oct 20, 2022

This has the potential to become slower over time if implemented poorly.

@penge
Copy link
Owner

penge commented Oct 20, 2022

What would the performance implications be though, if I've been using the extension for 365 days, and I only want the count for today, the code will need to process all blocks that have occurred in the last 365 days to find the block count for today.

If you would let's say open youtube.com which is blocked, 1 000 000 times over the past 365 days, it would take, to get that information for today, even in an unoptimized way of going over every record, roughly 35 milliseconds. In other words, 1/30 of a second. Woudn't notice a slowdown.

It could be optimized in many ways, for sure. Not saying it is needed, but for example, you don't have to go over everything to find records for Today. You could start at the end and go backwards until you find something else as Today (which would be Yesterday). With this simple optimization, you'd go over only 1/365 (just an example, only valid when you'd have same counts for every day) of all records only and make it thus as fast as 0,1 millisecond. In other words, 1/10000 of a second.

I wound't worry about the performance really. But glad you asked. If curious, you can try this by yourself.

/**
 * Repeats 10-times:
 * Creates an array of "length" with random numbers in range <0, 1)
 * and filters numbers down to numbers that are >0.5.
 * 
 * And prints:
 * - each run duration in ms
 * - average run duration in ms
*/
const test = (length) => {
  const durations = [];
  for (let r = 1; r <= 10; r++) {
    const arr = Array(length).fill().map(() => Math.random());
    const startTime = performance.now();
    const filtered = arr.filter((item) => item > 0.5);
    const endTime = performance.now();
    const duration = endTime - startTime;
    durations.push(duration);
    console.log(`run ${r} duration: ${duration} ms`);
  }
  const averageDuration = durations.reduce((p, c) => p + c, 0) / durations.length;
  console.log(`average run duration: ${averageDuration} ms`);
};


test(1_000_000); // try a different length

@olfek
Copy link
Contributor Author

olfek commented Oct 21, 2022

You could start at the end and go backwards until you find something else as Today (which would be Yesterday).

This is assuming that the counter data retrieved from storage is in the correct order, is that the case?

Is the correct order guaranteed?

@penge
Copy link
Owner

penge commented Oct 21, 2022

Every blocking is always added to the end. The order is guaranteed.

@penge
Copy link
Owner

penge commented Nov 6, 2022

@olfek

This feature is now implemented. Here's a preview:

count-period.mov

When you change option to "Show Blocked info page", it would show additional and related options in that area, to show how many times blocked [Yes/No], and blocked period [All Time, This Month, This Week, Today].

Blocked info page message would then depend on the selected period:

youtube.com was blocked 42x.

youtube.com was blocked 38x this month.

youtube.com was blocked 12x this week.

youtube.com was blocked 5x today.

As you can see, any other than "All Time" period is included in the message.

Other changes:

  • I have replaced checkboxes with more descriptive Yes/No and gave options the same work & feel - just dropdowns.
  • All changes saved automatically as before. And now, all changes also synced across other Options pages (not related to sync storage), in case Options are open multiple times (same window, other windows), any changes in options will be applied elsewhere.

What do you think?

@olfek
Copy link
Contributor Author

olfek commented Nov 7, 2022

@penge looks good to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants