Least-squares fitting (LsqFit): fit a sum

Dear community,

The code below fits the following model: sales = b1 / ranks^b2.

Given that sales are observed on a weekly basis (w) and ranks on a daily basis (t), how can I modify my code to fit the following model: sales_w = Sum_(t belong to week w) [b1 / ranks_t^b2]

Thank you in advance for your help!

using DataFrames
using StatFiles #read stata file
using LsqFit #least-squares fitting 

### load data
df = DataFrame(load("Data/AB.dta"))
rank =  df.rank
sales = df.sales
week = df.week

### Model 
# function to minimize
model(x, b) = b[1] ./ (x.^b[2])
# starting values
p0 = [10167, 0.45]
# fitting
fit = curve_fit(model, rank, sales, p0)
using DataFrames

# Parameters
b1 = 3.0;
b2 = 1.5;
# There are 6 days in 2 weeks
sales = [2.0, 3.0];
df = DataFrame(:week => [1,2,1,2,1,2], :rank => collect(LinRange(1.0, 2.0, 6)));
gdf = combine(groupby(df, :week), :rank => (x -> sum(b1 ./ x .^ b2)) => :wkrank);

results in

2×2 DataFrame
 Row │ week   wkrank
     │ Int64  Float64
─────┼────────────────
   1 │     1  6.0533
   2 │     2  4.82516

Thank you!