(campaign: Campaign)
| 31 | /** A completed boost's daily budget and days. A stopped one ended early, so |
| 32 | * its days no longer tell what it was set to */ |
| 33 | export const lastBoostOf = (campaign: Campaign): LastBoost | undefined => { |
| 34 | if (campaign.state !== CampaignState.Completed || !campaign.flags?.budget) { |
| 35 | return undefined; |
| 36 | } |
| 37 | |
| 38 | const totalDays = Math.max( |
| 39 | 1, |
| 40 | Math.round( |
| 41 | (new Date(campaign.endedAt).getTime() - |
| 42 | new Date(campaign.createdAt).getTime()) / |
| 43 | oneDay, |
| 44 | ), |
| 45 | ); |
| 46 | |
| 47 | return { |
| 48 | totalDays, |
| 49 | coresPerDay: Math.round(campaign.flags.budget / totalDays), |
| 50 | }; |
| 51 | }; |
no outgoing calls
no test coverage detected