Skip to content

Commit

Permalink
Merge pull request #114 from Carifio24/forecast-card-time
Browse files Browse the repository at this point in the history
Add forecast card time
  • Loading branch information
Carifio24 authored Apr 4, 2024
2 parents 93880c4 + 64507b6 commit e95caf6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
46 changes: 27 additions & 19 deletions src/stories/solar-eclipse-2024/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,39 @@ type SolarEclipse2024UpdateAttributes = UpdateAttributes<SolarEclipse2024Data>;
initializeModels(cosmicdsDB);

const LatLonArray = S.mutable(S.array(S.mutable(S.tuple(S.number, S.number))));
const OptionalInt = S.optional(S.number.pipe(S.int()), { exact: true });
const OptionalLatLonArray = S.optional(LatLonArray, { exact: true });


export const SolarEclipse2024Entry = S.struct({
user_uuid: S.string,
user_selected_locations: LatLonArray,
cloud_cover_selected_locations: LatLonArray,
text_search_selected_locations: LatLonArray,
advanced_weather_selected_locations_count: S.optional(S.number, { exact: true }),
cloud_cover_selected_locations_count: S.optional(S.number, { exact: true }),
info_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
app_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
advanced_weather_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
weather_info_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
user_guide_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
eclipse_timer_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
advanced_weather_selected_locations_count: OptionalInt,
cloud_cover_selected_locations_count: OptionalInt,
info_time_ms: OptionalInt,
app_time_ms: OptionalInt,
advanced_weather_time_ms: OptionalInt,
weather_info_time_ms: OptionalInt,
user_guide_time_ms: OptionalInt,
eclipse_timer_time_ms: OptionalInt,
forecast_info_time_ms: OptionalInt,
});

export const SolarEclipse2024Update = S.struct({
user_selected_locations: S.optional(LatLonArray, { exact: true }),
cloud_cover_selected_locations: S.optional(LatLonArray, { exact: true }),
text_search_selected_locations: S.optional(LatLonArray, { exact: true }),
delta_advanced_weather_selected_locations_count: S.optional(S.number, { exact: true }),
delta_cloud_cover_selected_locations_count: S.optional(S.number, { exact: true }),
delta_info_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
delta_app_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
delta_advanced_weather_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
delta_weather_info_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
delta_user_guide_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
delta_eclipse_timer_time_ms: S.optional(S.number.pipe(S.int()), { exact: true }),
user_selected_locations: OptionalLatLonArray,
cloud_cover_selected_locations: OptionalLatLonArray,
text_search_selected_locations: OptionalLatLonArray,
delta_advanced_weather_selected_locations_count: OptionalInt,
delta_cloud_cover_selected_locations_count: OptionalInt,
delta_info_time_ms: OptionalInt,
delta_app_time_ms: OptionalInt,
delta_advanced_weather_time_ms: OptionalInt,
delta_weather_info_time_ms: OptionalInt,
delta_user_guide_time_ms: OptionalInt,
delta_eclipse_timer_time_ms: OptionalInt,
delta_forecast_info_time_ms: OptionalInt,
});

export type SolarEclipse2024EntryT = S.Schema.To<typeof SolarEclipse2024Entry>;
Expand Down Expand Up @@ -111,6 +116,9 @@ export async function updateSolarEclipse2024Data(userUUID: string, update: Solar
if (update.delta_eclipse_timer_time_ms) {
dbUpdate.eclipse_timer_time_ms = data.eclipse_timer_time_ms + update.delta_eclipse_timer_time_ms;
}
if (update.delta_forecast_info_time_ms) {
dbUpdate.forecast_info_time_ms = data.forecast_info_time_ms + update.delta_forecast_info_time_ms;
}
const result = await data.update(dbUpdate);
return result !== null;
}
6 changes: 6 additions & 0 deletions src/stories/solar-eclipse-2024/models/eclipse_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class SolarEclipse2024Data extends Model<InferAttributes<SolarEclipse2024
declare weather_info_time_ms: CreationOptional<number>;
declare user_guide_time_ms: CreationOptional<number>;
declare eclipse_timer_time_ms: CreationOptional<number>;
declare forecast_info_time_ms: CreationOptional<number>;
declare timestamp: CreationOptional<Date>;
}

Expand Down Expand Up @@ -90,6 +91,11 @@ export function initializeSolarEclipse2024DataModel(sequelize: Sequelize) {
allowNull: false,
defaultValue: 0
},
forecast_info_time_ms: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0
},
timestamp: {
type: DataTypes.DATE,
allowNull: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CREATE TABLE SolarEclipse2024Data (
weather_info_time_ms INT NOT NULL DEFAULT 0,
user_guide_time_ms INT NOT NULL DEFAULT 0,
eclipse_timer_time_ms INT NOT NULL DEFAULT 0,
forecast_info_time_ms INT NOT NULL DEFAULT 0,
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

PRIMARY KEY(id),
Expand Down

0 comments on commit e95caf6

Please sign in to comment.