Skip to content

Comments

minimize calls to firebase for job status data#109

Merged
ascibisz merged 4 commits intomainfrom
maint/cleanup-firebase-functions
Oct 17, 2025
Merged

minimize calls to firebase for job status data#109
ascibisz merged 4 commits intomainfrom
maint/cleanup-firebase-functions

Conversation

@ascibisz
Copy link
Contributor

@ascibisz ascibisz commented Oct 10, 2025

Problem

When I was doing firebase cleanup, I went through our firebase utility functions to make sure we didn't have any dead code around that wasn't being used and if we had any redundant calls. I found a bit of each. This PR is to eliminate that for code clarity and performance.

Offshoot of this ticket

Solution

  • Delete firebase functions and types that aren't being referenced anywhere
  • Minimize queries to the job_status firebase collection.
    • We query this periodically while the cellpack job is running in AWS ECS to check the status, and then when we see that it's done, we have 3 additional queries: 1 to get the error logs, 1 to get the results path, and 1 to get the output directory path.
    • These are all just different fields saved in the same entry in the job_status collection! We can eliminate these 3 additional queries by just holding on to the whole job status object in the first place, instead of just keeping the value of a single field from each call.
    • One caveat: output directory path may not have been updated at the time of job completion if uploading is taking too long. So we handle that case by doing a check when the user selects "download results" and if needed, we can do an additional firebase query at that time to get the outputs directory. This is in the same place where we were always querying firebase for the outputs directory before

@github-actions
Copy link

github-actions bot commented Oct 10, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 24.42% 364 / 1490
🔵 Statements 24.42% 364 / 1490
🔵 Functions 41.07% 23 / 56
🔵 Branches 72.07% 80 / 111
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/App.tsx 0% 0% 0% 0% 1-13, 15-16, 18-24, 26, 28-30, 32-35, 37-47, 49-65, 67-82, 84-87, 89-108, 110, 112-124, 126, 128
src/components/ErrorLogs/index.tsx 0% 0% 0% 0% 1-3, 9-11, 13-22, 24, 26-33, 35, 37
src/components/StatusBar/index.tsx 0% 0% 0% 0% 1-5, 14-16, 18-22, 24, 26-39, 41, 43, 45, 47
src/types/index.ts 0% 100% 100% 0% 8, 16, 65, 101, 115, 136, 151
src/utils/aws.ts 0% 0% 0% 0% 1, 6-10, 12-15, 17-20, 22-27, 29-30, 32-36, 38-40, 42, 44-46, 48, 50-51, 53-55, 57-66, 68-76, 78-79, 81-82, 85-88
src/utils/firebase.ts 34.43% 62.5% 26.66% 34.43% 33-34, 39-40, 74-76, 79-84, 87-91, 94-99, 103-111, 114-116, 119-121, 124-143, 146-162, 176-177, 180-184, 186-193, 195, 197-199, 201-204
Generated in workflow #94

@github-actions
Copy link

github-actions bot commented Oct 10, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-10-17 23:08 UTC

export type FirebaseDict = {
[key: string]: Dictionary<string>;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these types were being used anywhere, so I deleted them

Base automatically changed from maint/firebase-cleanup to main October 13, 2025 16:40
@ascibisz ascibisz marked this pull request as ready for review October 13, 2025 19:45
@ascibisz ascibisz requested review from Copilot and rugeli October 13, 2025 19:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes Firebase usage by eliminating redundant queries and removing unused code. Instead of making separate queries for job status, error logs, results path, and output directory, the code now retrieves the complete job status object once and extracts all needed fields from it.

  • Consolidates multiple Firebase queries into a single query for job status data
  • Removes unused Firebase utility functions and types
  • Updates components to use the consolidated job status object

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/firebase.ts Removes unused functions, modifies getJobStatus to return full JobStatusObject instead of just status field
src/utils/aws.ts Updates downloadOutputs to accept optional outputsDir parameter to avoid redundant Firebase queries
src/types/index.ts Adds JobStatusObject type definition and removes unused interface types
src/constants/firebase.ts Removes unused EXAMPLE_RECIPES collection constant
src/components/StatusBar/index.tsx Accepts outputDir prop to pass to downloadOutputs function
src/components/ErrorLogs/index.tsx Removes getLogs prop since error logs are now provided directly
src/App.tsx Updates job status checking logic to use full JobStatusObject and extract needed fields locally

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ascibisz ascibisz requested a review from interim17 October 15, 2025 16:44
Copy link
Contributor

@rugeli rugeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me! so much cleaner

@ascibisz ascibisz force-pushed the maint/cleanup-firebase-functions branch from 80e870d to 06e4f87 Compare October 17, 2025 23:04
@ascibisz ascibisz merged commit 5e5862f into main Oct 17, 2025
2 checks passed
@ascibisz ascibisz deleted the maint/cleanup-firebase-functions branch October 17, 2025 23:08
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

Successfully merging this pull request may close these issues.

2 participants