GithubHelp home page GithubHelp logo

checkin-viz's Introduction

Checkinarator Visualizer

Simple chart generator which displays checkins by those in the challenges

Running the App

This app is dockerized and can be both run locally or as a container.

Dependencies

This app uses poetry for dependency managment. Install poetry following the instructions on their site and then run poetry install. From there use poetry shell and then the entrypoint with python src/main.py.

Secrets

In order to access the data in the database DB_CONNECT_STRING needs to be set. This value is stored in a sops encrypted .env file and can be encrypted and decrypted using the scripts in ./scripts assuming you have access to an allowed key. Before you can access these secrets you'll have to generate a new age key pair and provide your public key to someone who already has access. Once they resign the secrete with your public key you'll be able to decrypt using the decrypt script.

checkin-viz's People

Contributors

trescenzi avatar

Watchers

Lucian avatar  avatar  avatar

checkin-viz's Issues

Change Green Week calculation

This code probably won’t plug perfectly into what you’ve got but I’m posting it here in case it’s a useful starting point.

My goal is to have the probability of a green week ramp upward every week so there’s a guaranteed green week every 6 weeks, but never on the first week of a challenge.

After a Green Week, the probability ramp should reset.

Here’s the code and explanation:

@app.route("/make-it-green")
def make_it_green():
challenge_week = get_current_challenge_week()
week_number = challenge_week.week_number # Assuming this attribute exists

# Calculate the week number within the current 6-week cycle
week_in_cycle = (week_number - 1) % 6 + 1

# Define the probability for each week in the cycle
probabilities = [0, 20, 40, 60, 80, 100]

# Determine if it's a green week based on the ramping probability
green_chance = probabilities[week_in_cycle - 1]
green = random.randint(1, 100) <= green_chance

logging.debug("Is it green week: %s (Week %d in cycle, Chance: %d%%)", 
              green, week_in_cycle, green_chance)

if challenge_week.green is None:
    challenge_week.green = green
    challenge_week.save()

return render_template("green.html", green=green)

Let's break down the changes and explain how this new version works:

1. We calculate the week number within the current 6-week cycle:
   ```python
   week_in_cycle = (week_number - 1) % 6 + 1

This gives us a number from 1 to 6, representing the position in the current cycle.

  1. We define a list of probabilities for each week in the cycle:

    probabilities = [0, 20, 40, 60, 80, 100]

    This means:

    • Week 1: 0% chance (never green)
    • Week 2: 20% chance
    • Week 3: 40% chance
    • Week 4: 60% chance
    • Week 5: 80% chance
    • Week 6: 100% chance (guaranteed green if not green yet)
  2. We determine if it's a green week based on the ramping probability:

    green_chance = probabilities[week_in_cycle - 1]
    green = random.randint(1, 100) <= green_chance

    This checks if a random number (1-100) is less than or equal to the chance for that week.

  3. We've updated the logging to show the week number in the cycle and the chance of being green.

This approach ensures:

  • The probability of a green week increases each week within a 6-week cycle.
  • Week 1 is never green (0% chance).
  • Week 6 is always green if a green week hasn't occurred yet in that cycle (100% chance).
  • There's a smooth ramp-up in probability, making later weeks more likely to be green.
  • Each 6-week cycle is independent, resetting the probabilities.

This method provides a good balance between predictability and variability. It ensures at least one green week every 6 weeks while still maintaining an element of surprise for weeks 2-5.

Allow math inside calculator fields

Every day that I check in I use a calculator to add my minutes up from different exercises, then I put that number into the Tier Calculator. It would be awesome if I could do the math directly in the calculator field and have it added for me.

image

This might conflict with the PIN/numpad keyboard on iPhone. Maybe there’s another version that includes the basic calculator operators like plus and minus? Or you could do an on-page calculator style input?

Highlight highest tier on calculator

image

Reveal each item’s tier result and draw an outline around whichever of the two values results in the higher tier.

If they both result in the same tier, do not draw an outline.

Add numpad with operators to Tier Calculator

Looks like there is a way to get a numpad keyboard with operator symbols on iOS.

image

Looks like input type [decimal] or [tel] might get us what we want.

image

@trescenzi This is probably the kind of thing I could play with in the code myself to find out if it worked, if there was a way for me to test the output. But I have to imagine it would be a whole lot of extra work to make that possible?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.