2024-12-05-Thursday


created: 2024-12-05 06:00 tags: - daily-notes


Thursday, December 05, 2024

<< Timestamps/2024/12-December/2024-12-04-Wednesday|Yesterday | Timestamps/2024/12-December/2024-12-06-Friday|Tomorrow >>


🎯 Goal

  • [x] Fix the Taskmaster App so that the history of changes to the table are tracked in the database.

🌟 Results

  • Fixed the Taskmaster App (or rather, identified what was wrong)
  • Started learning how to bulk upload data into my models via the creation of the bulk_upload_ideas custom command

🌱 Next Time

  • Figure out how to get data to temporarily transfer over to the Heroku app via curl through S3

📝 Notes

Yesterday I realized that my Taskmaster App hasn't been tracking the changes to my task states since April. I'll start by checking the Heroku logs to see why the tasks aren't being saved. If I get some kind of 400 Error when the task URL is saved I'll know it has something to do with the calling of the command. I'll check and see if my actions are actually changing the state of the underlying task.

It looks like I am able to change the state of the task via the UI, so it probably has something to do with the use of the simple_history.models.HistoricalRecords field (i.e changes are not being properly tracked here for some reason).

Nevermind! I just found the reason for my issue was because I was tracking changes by the creation date of the task (date_created), not the creation of the record tracking the change to the task (history_date). I found this by checking one of the dataclips in my Heroku Postgres Heroku Resource to get live feedback from the db. I updated the SQL of this to be:

SELECT history_user_id, name, history_date, is_checked_in, is_complete, notes  
FROM taskmaster_historicaltask
ORDER BY history_date DESC;

So that I don't get confused again in the future. I guess the easiest fixes are for the problems that never existed in the first place.

Next I wanted to find a way to Django Bulk Upload my ideas from my phone's notepad directly into my production-level app. There are a few hundred, so there's no way I'm uploading those manually. There has to be some efficient way to upload the data...

It looks like I can do this directly from the CLI without having to login to Heroku CLI. I created a file within a directory called apps/bigbrain/management/commands/bulk_upload_ideas.py with a command that can help load in data specifically to the ideas Django Model of the BigBrain App.

I was able to run

python manage.py bulk_upload_ideas "bulk_upload_data.txt"

but this only successfully updated my Local Version to include my ideas. Still a good start. I think I'll need to change my Environment Variables so that the DATABASE_URL points to the actual Heroku Postgres database instead of my local postgres://locahlost.

heroku config -a dimmin
export DATABASE_URL=above-database-url
python manage.py bulk_upload_ideas "bulk_upload_data.txt"

After changing the DATABASE_URL variable that didn't work. I decided to try uploading my file directly to heroku via the Heroku CLI. First I found that my Heroku CLI version was outdated, so I updated it via

heroku update

still didn't let me install the plugin I wanted that would let me send over my bulk_upload_data.txt file to heroku. I ended up uploading the file to S3 then executing this new bulk upload command:

heroku run bash -a dimmin
curl -o /tmp/bulk_upload_data.txt "pre-signed-url"

This transfers the file over to wherever Heroku is hosting it, but the pre-signed S3 URL doesn't seem to be valid (or rather, the request is invalid for some reason).


Notes created today

List FROM "" WHERE file.cday = date("2024-12-05") SORT file.ctime asc

Notes last touched today

List FROM "" WHERE file.mday = date("2024-12-05") SORT file.mtime asc

(Template referenced from Dann Berg, can be found here)


Previous Note 2024-12-04-Wednesday Next Note 2024-12-06-Friday