Skip to content

Commit 06042a5

Browse files
authored
Merge pull request #111 from Carifio24/cloud-cover-count
Get cloud cover count from request
2 parents 4c992cf + b556c8f commit 06042a5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/stories/solar-eclipse-2024/database.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const SolarEclipse2024Entry = S.struct({
1717
cloud_cover_selected_locations: LatLonArray,
1818
text_search_selected_locations: LatLonArray,
1919
advanced_weather_selected_locations_count: S.number,
20+
cloud_cover_selected_locations_count: S.optional(S.number, { exact: true }),
2021
info_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
2122
app_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
2223
advanced_weather_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
@@ -30,6 +31,7 @@ export const SolarEclipse2024Update = S.struct({
3031
cloud_cover_selected_locations: S.optional(LatLonArray, { exact: true }),
3132
text_search_selected_locations: S.optional(LatLonArray, { exact: true }),
3233
delta_advanced_weather_selected_locations_count: S.optional(S.number, { exact: true }),
34+
delta_cloud_cover_selected_locations_count: S.optional(S.number, { exact: true }),
3335
delta_info_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
3436
delta_app_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
3537
delta_advanced_weather_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
@@ -38,16 +40,16 @@ export const SolarEclipse2024Update = S.struct({
3840
delta_eclipse_timer_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
3941
});
4042

41-
export type SolarEclipse2024DataT = S.Schema.To<typeof SolarEclipse2024Entry>;
43+
export type SolarEclipse2024EntryT = S.Schema.To<typeof SolarEclipse2024Entry>;
4244
export type SolarEclipse2024UpdateT = S.Schema.To<typeof SolarEclipse2024Update>;
4345

44-
export async function submitSolarEclipse2024Data(data: SolarEclipse2024DataT): Promise<SolarEclipse2024Data | null> {
46+
export async function submitSolarEclipse2024Data(data: SolarEclipse2024EntryT): Promise<SolarEclipse2024Data | null> {
4547
logger.verbose(`Attempting to submit solar eclipse 2024 measurement for user ${data.user_uuid}`);
4648

4749
const dataWithCounts = {
4850
...data,
51+
cloud_cover_selected_locations_count: data.cloud_cover_selected_locations_count ?? data.cloud_cover_selected_locations.length,
4952
user_selected_locations_count: data.user_selected_locations.length,
50-
cloud_cover_selected_locations_count: data.cloud_cover_selected_locations.length,
5153
text_search_selected_locations_count: data.text_search_selected_locations.length,
5254
};
5355

@@ -88,6 +90,9 @@ export async function updateSolarEclipse2024Data(userUUID: string, update: Solar
8890
if (update.delta_advanced_weather_selected_locations_count) {
8991
dbUpdate.advanced_weather_selected_locations_count = data.advanced_weather_selected_locations_count + update.delta_advanced_weather_selected_locations_count;
9092
}
93+
if (update.delta_cloud_cover_selected_locations_count) {
94+
dbUpdate.cloud_cover_selected_locations_count = data.cloud_cover_selected_locations_count + update.delta_cloud_cover_selected_locations_count;
95+
}
9196
if (update.delta_info_time_ms) {
9297
dbUpdate.info_time_ms = data.info_time_ms + update.delta_info_time_ms;
9398
}

0 commit comments

Comments
 (0)