Giter Club home page Giter Club logo

hack-hour's Introduction

Hack Hour (Arcade)

Hack Hour is a project tracker & time management tool for hacking on projects. It's currently being used to track hours as a part of Hack Club's Arcade and is on slack as @hakkuun (but her name is heidi ๐Ÿ˜Š).

API

Note: There is no guarantee for the reliability of the API. If data is lost and/or is not registered for Arcade, there's not much we can do - use at your own risk.

All endpoints require an authorization header with the api key, as such: Authorization: Bearer <apikey>

GET /api/session/:slackId

Gets the latest session for the user.

Example Response:

{
    "ok": true,
    "data": {
        "id": "slackId",
        "createdAt": "2024-06-23T02:49:17.900Z",
        "time": 60,
        "elapsed": 12,
        "remaining": 48,
        "endTime": "2024-06-23T03:08:00.000Z",
        "goal": "No Goal",
        "paused": true,
        "completed": false,
        "messageTs": "messageTs",
    }
}

GET /api/stats/:slackId

Gets the stats for the user.

Example Response:

{
    "ok": true,
    "data": {
        "sessions": 0,
        "total": 0,
    }
}

GET /api/goals/:slackId

Gets the goals for the user.

Example Response:

{
    "ok": true,
    "data": [
        {
            "name": "No Goal",
            "minutes": 0
        }
    ]
}

GET /api/history/:slackId

Gets the history for the user.

Example Response:

{
    "ok": true,
    "data": [
        {
            "createdAt": "2024-06-23T05:09:04.105Z",
            "time": 60,
            "elapsed": 23,
            "goal": "No Goal",
            "ended": false,
            "work": "123"
        }
    ]
}

POST /api/start/:slackId

Starts a new session for the user.

Requires a JSON body with the following fields:

  • work: what the user is working on (string)

Example Response:

{
    "ok": true,
    "data": {
        "id": "sessionId",
        "slackId": "slackId",
        "createdAt": "createdAt",
    }
}

POST /api/pause/:slackId

Pauses or resumes the current session for the user, depending on the current state.

Requires an authorization header with the api key, as such: Authorization: Bearer <apikey>

Example Response:

{
    "ok": true,
    "data": {
        "id": "sessionId",
        "slackId": "slackId",
        "createdAt": "createdAt",
        "paused": true,
    }
}

POST /api/cancel/:slackId

Cancels the current session for the user.

Requires an authorization header with the api key, as such: Authorization Bearer <apikey>

Example Response:

{
    "ok": true,
    "data": {
        "id": "sessionId",
        "slackId": "slackId",
        "createdAt": "createdAt",
    }
}

API - No Auth

GET /ping

Returns with pong. Check if the thing is alive

GET /status

Get specific details on the status of hack hour (heidi)

Example Response:

{
    "activeSessions": -1,
    "airtableConnected": false,
    "slackConnected": false,
}

GET /api/clock/:slackId

Depreciated.

Responds with unix timestamp of the expected end time of the current session for the user.

hack-hour's People

Contributors

24c02 avatar adammakesthingsdev avatar albert-du avatar anishanne avatar averseabfun avatar bellesea avatar chardynamics avatar datcodemania avatar dillonb07 avatar iris-therainbow avatar maxwofford avatar polypixeldev avatar polytroper avatar rutmanz avatar techpixel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hack-hour's Issues

Please add README file

Adding a README file/intro on how things in the project is laid would help others to help/engage in the codebase.

more stats on the shop

the shop (/shop) should list:

  • total ๐ŸŽŸ๏ธ
  • current ๐ŸŽŸ๏ธ available for spending
  • ๐ŸŽŸ๏ธ locked up in current orders

commit link vs repo link

currently when we detect if a 'scrap' has been posted we check for github.com/user/repo linksโ€“ that shouldn't count the same way a specific commit link counts b/c users are spending 5 sessions & all link "github.com/user/repo", which means I can only approve 1 of the hours

Listen to Scrapbook & Github Commits

Tasks

Sessions should be attached to a scrapbook in order

Screenshot 2024-07-03 at 10 18 32

Currently sessions are associated with scrapbooks in airtable with a random order (I suspect it's the order they were selected in slack at the "select the sessions you want to scrapbook" step). We should sort those by creation date to make sure that sessions are in order.

Return `/sessions`

This was a useful command to browse sessions & their approval states, but was removed during rewriting & revisions.

Slack rate limits

We're getting rate-limited hard by slack & usability goes down when more than 50 active hack hours are running at the same time.

I'd like to setup a message queue for anything that's not 100% critical & send the message out with logic to prevent us getting ratelimited like this

Using timestamps to record session time instead of a counter

Hey hackclub HQ. It seems really unoptimal that we are using a minutes counter stored in a prisma database to record session time. Prisma takes around 2ms to update a record (https://benchmarks.prisma.io/?active_query=update). We are doing up to 4 update queries per session per minute, let's say about 2 on average. If we consider about 10k active users this comes down to 2ms * 10_000 * 2 = 40 seconds. This clock requires about 40 seconds of processing time per minute. If we go up to about 15k active users our time to update the records becomes longer than a minute.

I don't quite get why we would even store such often accessed data in a database. Numbers are about 8 bytes of data in javascript. We have an id which we need to store as well which are a 24 char long string which is 48 bytes. Together that comes to about 56 bytes. Take that times 15k (for every session we have) and it takes about 840000 bytes of memory to store this. That is 0.8 MB, not even a single megabyte.

Furthermore, we could use timestamps to make the whole act more efficient. We just store the timestamp when a session has started + additionally an minute offset integer, in which we will store the current minutes after we pause a session.

We can then calculate the elapsed time by using basic math let elapsed = now - sessionStarted + minuteOffset.

This is trivial to implement and still it improves the performance by a ton. Database queries are very slow. We should avoid them whenever possible. Yet we still do 2 for every session every minute. Why?

Only 25 session cap for each scrapbook!

Must #scrapbook at least once every 25 hours! If you're scrapbooking more hours then that it probably means people aren't shipping quick and shipping often.

Need to be a full user to run `/arcade`

We have a bunch of people not going through the tutorial all the way and just hanging out as partial usersโ€“ we're going to now require people get through the tutorial by making /arcade only work for full users.

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.