def METHOD_NAME(self, session, areaid, area_is_new):
    # Select all cells in this area and derive a bounding box for them
    radio, mcc, mnc, lac = decode_cellarea(areaid)
    load_fields = (
        "cellid",
        "lat",
        "lon",
        "radius",
        "region",
        "last_seen",
        "max_lat",
        "max_lon",
        "min_lat",
        "min_lon",
    )
    shard = self.cell_model.shard_model(radio)
    fields = [getattr(shard.__table__.c, f) for f in load_fields]
    cells = session.execute(
        select(fields)
        .where(shard.__table__.c.radio == radio)
        .where(shard.__table__.c.mcc == mcc)
        .where(shard.__table__.c.mnc == mnc)
        .where(shard.__table__.c.lac == lac)
        .where(shard.__table__.c.lat.isnot(None))
        .where(shard.__table__.c.lon.isnot(None))
    ).fetchall()
    if len(cells) == 0:
        # If there are no more underlying cells, delete the area entry
        session.execute(
            delete(self.area_table).where(self.area_table.c.areaid == areaid)
        )
        return
    # Otherwise update the area entry based on all the cells
    cell_extremes = numpy.array(
        [
            (
                numpy.nan if cell.max_lat is None else cell.max_lat,
                numpy.nan if cell.max_lon is None else cell.max_lon,
            )
            for cell in cells
        ]
        + [
            (
                numpy.nan if cell.min_lat is None else cell.min_lat,
                numpy.nan if cell.min_lon is None else cell.min_lon,
            )
            for cell in cells
        ],
        dtype=numpy.double,
    )
    max_lat, max_lon = numpy.nanmax(cell_extremes, axis=0)
    min_lat, min_lon = numpy.nanmin(cell_extremes, axis=0)
    ctr_lat, ctr_lon = numpy.array(
        [(c.lat, c.lon) for c in cells], dtype=numpy.double
    ).mean(axis=0)
    ctr_lat = float(ctr_lat)
    ctr_lon = float(ctr_lon)
    radius = circle_radius(ctr_lat, ctr_lon, max_lat, max_lon, min_lat, min_lon)
    cell_radii = numpy.array(
        [(numpy.nan if cell.radius is None else cell.radius) for cell in cells],
        dtype=numpy.int32,
    )
    avg_cell_radius = int(round(numpy.nanmean(cell_radii)))
    num_cells = len(cells)
    region = self.region(ctr_lat, ctr_lon, mcc, cells)
    last_seen = None
    cell_last_seen = set(
        [cell.last_seen for cell in cells if cell.last_seen is not None]
    )
    if cell_last_seen:
        last_seen = max(cell_last_seen)
    if area_is_new:
        session.execute(
            self.area_table.insert().values(
                areaid=areaid,
                radio=radio,
                mcc=mcc,
                mnc=mnc,
                lac=lac,
                created=self.utcnow,
                modified=self.utcnow,
                lat=ctr_lat,
                lon=ctr_lon,
                radius=radius,
                region=region,
                avg_cell_radius=avg_cell_radius,
                num_cells=num_cells,
                last_seen=last_seen,
            )
            # If there was an unexpected insert, log warning instead of error
            .prefix_with("IGNORE", dialect="mysql")
        )
    else:
        session.execute(
            self.area_table.update()
            .where(self.area_table.c.areaid == areaid)
            .values(
                modified=self.utcnow,
                lat=ctr_lat,
                lon=ctr_lon,
                radius=radius,
                region=region,
                avg_cell_radius=avg_cell_radius,
                num_cells=num_cells,
                last_seen=last_seen,
            )
        )