0.1 . succesfull test run.

This commit is contained in:
Charles N Wyble 2024-12-14 23:51:24 -06:00
parent a31d481243
commit e50770c4ef
6 changed files with 273 additions and 0 deletions

View File

@ -0,0 +1,23 @@
###################################################
# Modify these values to suit
###################################################
#############################################################################
#SET THIS NEXT VARIABLE OR NOTHING WILL WORK!!!!
export PipelineClientWorkingDir="D:/tsys/@ReachableCEO/DSR-Pipeline-ClientExample/local"
#SET THE PREVIOUS VARIABLE OR NOTHING WILL WORK!!!!
#############################################################################
##########################################
# Layout/title page /formatting options
##########################################
export ReportAuthor="First Middle Last"
export AuthorTagline="Your.Tagline.Here."
export AuthorLogo=""
export SourceCode="https://git.knownelement.com/reachableceo/MarkdownResume-Pipeline"
export URLCOLOR="blue"
export PAGEBACKGROUND="./background3.pdf"
export PANDOC_TEMPLATE="eisvogel"

View File

@ -0,0 +1,6 @@
# Demo Report
# Time log
1:00:
- stuff

View File

@ -0,0 +1,19 @@
# Data Gathering for the @ReachableCEO daily stakeholder report
## Introduction
I'm trying to life a fully instrumented CTO/founder life and #buildInPublic. And unlike most of the founders doing so, I'm actually publishing daily reports and live streaming my workstation all dya.
I want to automate the instrumentation/reporting process as much as possible to get the highest fidelity information for stakeholders consumption.
## Data sources
- Apple Health (exporting via AutoHealthExport)
- Workout (evaluating a cou
- Nutrition
- Daily habit tracking
- ActivityWatch
- WakaAPI
## Scripts

View File

@ -0,0 +1,83 @@
#!/bin/bash
# Script to query Gitea API for a user's activity on a specific date
########################################################################################################
#Obtain gitea api key from bitwarden
########################################################################################################
####################################
## Step 0: Set to use tsys server
####################################
bw logout
echo "Setting cli to use tsys bitwarden server..."
bw config server https://pwvault.turnsys.com
####################################
## Step 1: login to bitwarden
####################################
# From: https://bitwarden.com/help/cli/#using-an-api-key
### Set apikey environment varaible
echo "Sourcing clientid/apikey data..."
source D:/tsys/secrets/bitwarden/data/apikey-bitwarden-reachableceo
### Login to vault using apikey...
echo "Logging in..."
bw login --apikey $BW_CLIENTID $BW_CLIENTSECRET
### Step 1.1: unlock / save session id
echo "Unlocking..."
export BW_SESSION="$(bw unlock --passwordenv TSYS_BW_PASSWORD_REACHABLECEO --raw)"
### Step 2: retrive a value into an environment variable
export GITEA_APIKEY="$(bw get password APIKEY-Gitea)"
########################################################################################################
# Accrss gitea data
########################################################################################################
# Script to query Gitea API for a user's activity on a specific date
# Usage: ./get_gitea_user_activity.sh <username> <date> [GITEA_URL] [TOKEN]
# Set username, date, and default Gitea URL
USERNAME="${1:-reachableceo}" # Default to "reachableceo" if not provided
DATE="${2:-$(date +%Y-%m-%d)}" # Default to today's date if not provided
GITEA_URL="${3:-https://git.knownelement.com}" # Default Gitea URL if not provided
TOKEN="${GITEA_APIKEY}" # Use APIKEY-GItea or passed argument
# API Endpoint for user activities
API_ENDPOINT="$GITEA_URL/api/v1/users/$USERNAME/timeline"
# Make the API call
if [ -n "$TOKEN" ]; then
# If token is provided, use it in the Authorization header
RESPONSE=$(curl -s -H "Authorization: token $TOKEN" "$API_ENDPOINT")
else
# If no token is provided, make an unauthenticated request
RESPONSE=$(curl -s "$API_ENDPOINT")
fi
# Check for API errors
if [[ "$RESPONSE" == "Not found" || -z "$RESPONSE" ]]; then
echo "Error: User '$USERNAME' not found, or endpoint is incorrect."
exit 1
fi
# Validate JSON response
if ! echo "$RESPONSE" | jq empty >/dev/null 2>&1; then
echo "Error: Invalid JSON response from Gitea API."
echo "Response: $RESPONSE"
exit 1
fi
# Filter the activity by date using jq
echo "$RESPONSE" | jq --arg date "$DATE" '[.[] | select(.created_at | startswith($date))]'

View File

@ -0,0 +1,59 @@
#!/bin/bash
# Functions
# Search for a note by title and return its ID
search_note() {
local title="$1"
echo "Searching for note with title: $title"
note_id=$(joplin search "$title" --fields id --limit 1 --json | jq -r '.[0].id')
if [[ -z "$note_id" || "$note_id" == "null" ]]; then
echo "Error: Note with title '$title' not found."
exit 1
fi
echo "Found note with ID: $note_id"
echo "$note_id"
}
# Export the note by ID to the specified directory
export_note() {
local note_id="$1"
local output_dir="$2"
echo "Exporting note ID: $note_id to directory: $output_dir"
mkdir -p "$output_dir" || {
echo "Error: Unable to create directory $output_dir"
exit 1
}
# Export the note with attachments to the specified directory
joplin export "$note_id" --format md --output "$output_dir" || {
echo "Error: Failed to export note ID $note_id"
exit 1
}
echo "Note exported successfully to $output_dir"
}
# Main function
main() {
if [[ $# -lt 2 ]]; then
echo "Usage: $0 <note-title> <output-directory>"
exit 1
fi
local note_title="$1"
local output_dir="$2"
# Search for the note and get its ID
local note_id
note_id=$(search_note "$note_title")
# Export the note
export_note "$note_id" "$output_dir"
}
# Run the main function with all script arguments
main "$@"

View File

@ -0,0 +1,83 @@
#!/bin/bash
# Script to query Gitea API for a user's activity on a specific date
########################################################################################################
#Obtain gitea api key from bitwarden
########################################################################################################
####################################
## Step 0: Set to use tsys server
####################################
bw logout
echo "Setting cli to use tsys bitwarden server..."
bw config server https://pwvault.turnsys.com
####################################
## Step 1: login to bitwarden
####################################
# From: https://bitwarden.com/help/cli/#using-an-api-key
### Set apikey environment varaible
echo "Sourcing clientid/apikey data..."
source D:/tsys/secrets/bitwarden/data/apikey-bitwarden-reachableceo
### Login to vault using apikey...
echo "Logging in..."
bw login --apikey $BW_CLIENTID $BW_CLIENTSECRET
### Step 1.1: unlock / save session id
echo "Unlocking..."
export BW_SESSION="$(bw unlock --passwordenv TSYS_BW_PASSWORD_REACHABLECEO --raw)"
### Step 2: retrive a value into an environment variable
export GITEA_APIKEY="$(bw get password APIKEY-Gitea)"
########################################################################################################
# Accrss gitea data
########################################################################################################
# Script to query Gitea API for a user's activity on a specific date
# Usage: ./get_gitea_user_activity.sh <username> <date> [GITEA_URL] [TOKEN]
# Set username, date, and default Gitea URL
USERNAME="${1:-reachableceo}" # Default to "reachableceo" if not provided
DATE="${2:-$(date +%Y-%m-%d)}" # Default to today's date if not provided
GITEA_URL="${3:-https://git.knownelement.com}" # Default Gitea URL if not provided
TOKEN="${GITEA_APIKEY}" # Use APIKEY-GItea or passed argument
# API Endpoint for user activities
API_ENDPOINT="$GITEA_URL/api/v1/users/$USERNAME/timeline"
# Make the API call
if [ -n "$TOKEN" ]; then
# If token is provided, use it in the Authorization header
RESPONSE=$(curl -s -H "Authorization: token $TOKEN" "$API_ENDPOINT")
else
# If no token is provided, make an unauthenticated request
RESPONSE=$(curl -s "$API_ENDPOINT")
fi
# Check for API errors
if [[ "$RESPONSE" == "Not found" || -z "$RESPONSE" ]]; then
echo "Error: User '$USERNAME' not found, or endpoint is incorrect."
exit 1
fi
# Validate JSON response
if ! echo "$RESPONSE" | jq empty >/dev/null 2>&1; then
echo "Error: Invalid JSON response from Gitea API."
echo "Response: $RESPONSE"
exit 1
fi
# Filter the activity by date using jq
echo "$RESPONSE" | jq --arg date "$DATE" '[.[] | select(.created_at | startswith($date))]'