added 260907 version of worker toolkit

This commit is contained in:
2026-09-08 20:30:51 -04:00
parent cbd3f0f8ca
commit 97aca37663
1283 changed files with 142951 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,101 @@
DAYS = 60
email = ENV["CHECKINS_FOR"]
if email.present?
puts "email=#{email}"
user = User.find_or_create_by(email: email)
# Delete all Tracking, Checkin and Tag
Tracking.destroy_all
Checkin.destroy_all
Checkin::Tag.destroy_all
# Set locale to default
I18n.locale = I18n.default_locale
# Create some trackables (both global and personal)
conditions = FactoryBot.create_list(:user_condition, 2, user: user).map(&:condition)
conditions += FactoryBot.create_list(:condition, 3)
symptoms = FactoryBot.create_list(:user_symptom, 2, user: user).map(&:symptom)
symptoms += FactoryBot.create_list(:symptom, 5)
treatments = FactoryBot.create_list(:user_treatment, 3, user: user).map(&:treatment)
treatments += FactoryBot.create_list(:treatment, 6)
# Create some tags
tags = FactoryBot.create_list(:tag, 10)
# Setup time frame
end_at = Date.today
day = end_at - (DAYS - 1).days
# Start tracking some trackable
2.times do
condition = conditions.pop
Tracking.create!(user: user, trackable: condition, start_at: day)
puts "Start tracking #{condition.name}"
end
3.times do
symptom = symptoms.pop
Tracking.create!(user: user, trackable: symptom, start_at: day)
puts "Start tracking #{symptom.name}"
end
4.times do
treatment = treatments.pop
Tracking.create!(user: user, trackable: treatment, start_at: day)
puts "Start tracking #{treatment.name}"
end
# Iterate on days
i = 1
divisors_range_start = DAYS / 4 + 2
divisors_range = (divisors_range_start..divisors_range_start + 2)
while day <= end_at
puts "\n\n=== Day: #{day} ==="
active_trackings = user.trackings.active_at(day).to_a
# Stop tracking something at some random iteration
if i % divisors_range.to_a.sample == 0
tracking = active_trackings.sample
tracking.update!(end_at: day)
puts "Stop tracking #{tracking.trackable.name}"
end
# Start tracking something at some random iteration
# (either something new, or something tracked earlier)
if i % divisors_range.to_a.sample == 0
tracked_earlier = (user.trackings.to_a - active_trackings.to_a).map(&:trackable)
trackables_matrix = [conditions, treatments, tracked_earlier, symptoms]
trackables = []
trackables = trackables_matrix.pop while trackables.empty?
trackable = trackables.pop
Tracking.create!(user: user, trackable: trackable, start_at: day)
puts "Start tracking #{trackable.name}"
end
# Checkin
checkin = FactoryBot.create(:checkin,
user_id: user.id, date: day, tag_ids: tags.sample(3).map(&:id))
active_trackings = user.trackings.reload.active_at(day)
active_trackings.map(&:trackable).each do |trackable|
if trackable.is_a? Condition
condition_checkin = FactoryBot.create(
:checkin_condition, checkin: checkin, condition_id: trackable.id
)
puts "Checked-in #{trackable.name}, value: #{condition_checkin.value}"
elsif trackable.is_a? Symptom
symptom_checkin = FactoryBot.create(
:checkin_symptom, checkin: checkin, symptom_id: trackable.id
)
puts "Checked-in #{trackable.name}, value: #{symptom_checkin.value}"
elsif trackable.is_a? Treatment
treatment_checkin = FactoryBot.create(
:checkin_treatment, checkin: checkin, treatment_id: trackable.id
)
puts "Checked-in #{trackable.name}, value: #{treatment_checkin.value}"
end
end
day += 1.day
i += 1
end
end

View File

@@ -0,0 +1,5 @@
[
"test@flaredown.com"
].each do |email|
FactoryBot.create(:user, email: email) unless User.exists?(email: email)
end

View File

@@ -0,0 +1,249 @@
SEED_SYMPTOMS = [
"Abdominal pain",
"Absence of speech",
"Allergy",
"Altered mental status",
"Anal itching",
"Anemia",
"Ankle pain",
"Anxiety",
"Aphasia",
"Arm pain",
"Attention deficit",
"Back pain",
"Bad breath",
"Bad taste in the mouth",
"Beau's lines",
"Behavior disorder",
"Bladder spasms",
"Bleeding gums",
"Blisters",
"Blood in semen",
"Blood in urine",
"Bloody nose",
"Bloody sputum",
"Blunted affect",
"Blurred vision",
"Bowel incontinence",
"Breast discharge",
"Breast lumps",
"Breast pain",
"Brittle nails",
"Bumps on skin",
"Burning urination",
"Buttock pain",
"Catatonia",
"Chest pain",
"Chills",
"Chronic pain",
"Cloudy urine",
"Coccydynia",
"Cold",
"Cold feet",
"Cold fingers",
"Cold hands",
"Confusion",
"Constipation",
"Cough",
"Cyanosis/turning blue",
"Dark circles under the eyes",
"Dark urine",
"Decreased appetite",
"Delirium",
"Delusions",
"Depigmentation of skin",
"Depression",
"Detrusor contraction",
"Diarrhea",
"Difficulty concentrating",
"Difficulty urinating",
"Difficulty with speech",
"Dilated pupils",
"Discharge from penis",
"Distended stomach",
"Dizziness",
"Double vision",
"Drainage of pus",
"Drooling",
"Dry eye",
"Dry mouth",
"Dry skin",
"Dysarthria",
"Dyspepsia",
"Dysphagia",
"Earache",
"Easy bruising",
"Elbow pain",
"Emotional disorder",
"Enlarged heart",
"Euphoria",
"Excessive sweating",
"Eye discharge",
"Eye pain",
"Eye twitch",
"Fainting",
"Fatigue and tiredness",
"Fecal incontinence",
"Fever",
"Finger pain",
"Flaky scalp",
"Flat affect",
"Fluctuating mood",
"Foot pain",
"Frequent urination",
"Gas",
"Hair loss",
"Hairy tongue",
"Hallucinations",
"Hand pain",
"Headache",
"Hearing loss",
"Heartburn",
"Heel pain",
"Hemolysis",
"Hemolytic anemia",
"Hip pain",
"Hoarseness",
"Hot flashes",
"Hyperactivity",
"Hyperventilation",
"Impotence",
"Impulsivity",
"Inability to regulate emotions",
"Inattention",
"Incontinence,
urine",
"Increased appetite",
"Infertility",
"Insomnia",
"Itch",
"Jaundice",
"Jaw pain",
"Joint cracking",
"Joint pain",
"Joint redness",
"Joint stiffness",
"Knee pain",
"Koilonychia",
"Labile mood",
"Leg pain",
"Leg sores",
"Leg swelling",
"Limping",
"Loss of appetite",
"Loss of speech",
"Loss of taste sensation",
"Loss of temperature sensation",
"Low libido",
"Low urine output",
"Lump or mass on gums",
"Memory loss",
"Menstrual cramps",
"Metallic taste in the mouth",
"Missed menstrual period",
"Mood swings",
"Mouth sores",
"Muscle cramps",
"Muscle pain",
"Mutism",
"Nail clubbing",
"Nail discoloration",
"Nail pitting",
"Nail separation",
"Nasal congestion",
"Nausea",
"Neck pain",
"Neglecting oneself",
"Numbness fingers",
"Numbness or tingling sensation in the tongue",
"Numbness toes",
"Onychorrhexis",
"Overactive bladder",
"Pain in the penis",
"Painful gums",
"Painful intercourse",
"Pale skin",
"Palpitations",
"Paralysis",
"Paranoia",
"Peeling skin",
"Pelvic pain",
"Penile discharge",
"Penile itching",
"Penile pain",
"Peripheral neuropathy",
"Photophobia",
"Pink eye",
"Pleurisy",
"Poor hygiene",
"Proteinuria",
"Ptosis",
"Rash",
"Rectal bleeding",
"Rectal incontinence",
"Rectal pain",
"Red spots on the skin",
"Red streaks on the skin",
"Restless leg syndrome",
"Ringing in ears",
"Runny nose",
"Seizures",
"Self-neglect",
"Shaking hands",
"Shortness of breath",
"Shoulder pain",
"Snoring",
"Sore throat",
"Sore tongue",
"Stiff neck",
"Stomach cramps",
"Stool color & texture changes",
"Strange behavior",
"Suicide",
"Swollen ankles and/or swollen feet",
"Swollen eyes",
"Swollen joints",
"Swollen lip",
"Swollen lymph nodes",
"Swollen testicles",
"Swollen tongue",
"Swollen tonsils",
"Tachycardia",
"Testicular pain",
"Thirst",
"Tingling in hands and feet",
"Toe pain",
"Toothache",
"Tremor",
"Tunnel vision",
"Unsteady gait",
"Unusual behavior",
"Urge incontinence",
"Urinary retention",
"Urinary urgency",
"Urine odor",
"Vaginal bleeding",
"Vaginal discharge",
"Vaginal dryness",
"Vaginal itching",
"Vaginal odor",
"Vaginal pain",
"Vertical ridges on the fingernails",
"Vertigo",
"Vision loss",
"Vocal outbursts",
"Vomiting",
"Vomiting blood",
"Watery eye",
"Weakness",
"Weight gain",
"Weight loss",
"Wheezing",
"White tongue",
"Wrist pain"
]
I18n.locale = :en
SEED_SYMPTOMS.each do |name|
Symptom.find_or_create_by!(name: name)
end

File diff suppressed because it is too large Load Diff