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

history of use #135

Open
nsheff opened this issue Aug 27, 2024 · 0 comments
Open

history of use #135

nsheff opened this issue Aug 27, 2024 · 0 comments
Assignees

Comments

@nsheff
Copy link
Member

nsheff commented Aug 27, 2024

Let's build a simple tracker to monitor use over time.

It has 3 components: 1. database table; 2. variable (in memory), 3. background task using fastapi background task. or using async io to do something like repeat every

back-end

Table looks something like this

Table name: usage (? or journal or history or something?)
Columns: timestamp, variable_name, value

Then in the database agent, make function report_result or journal_entry or something, that just is like agent.journal_entry(today(), "users", number_of_files. And then maybe something like fetch_result` that can take a particular variable name

functions

Now we need a few variables to store.
One could be num_bed_files, which just returns the COUNT of number of files, from the database. we just want to record how this changes over time.

For this one, write a background task that will run every 7 days, entering a journal entry.

Then, there can be another one, which is num_requests_served. For this one, we would have an environment variable in the app, maybe called USAGE ={}. Add to the endpoint an incrementer so whenever someone hits the endpoint X, you do USAGE['endponit-x'] += 1. Then, set up a background task to @repeat_every 7 days, and have it take the value and add it to the existing value in the database, with a new entry, under today's timestamp, and then reset the USAGE variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants