Skip to content

Commit

Permalink
Merge pull request #107 from Carifio24/advanced-weather-info-time
Browse files Browse the repository at this point in the history
Add advanced weather info time
  • Loading branch information
Carifio24 authored Mar 15, 2024
2 parents 82e7b36 + 801a3c0 commit 7bf0b4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/stories/solar-eclipse-2024/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const SolarEclipse2024Entry = S.struct({
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 }),
});

export const SolarEclipse2024Update = S.struct({
Expand All @@ -26,6 +27,7 @@ export const SolarEclipse2024Update = S.struct({
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 }),
});

export type SolarEclipse2024DataT = S.Schema.To<typeof SolarEclipse2024Entry>;
Expand Down Expand Up @@ -78,6 +80,9 @@ export async function updateSolarEclipse2024Data(userUUID: string, update: Solar
if (update.delta_advanced_weather_time_ms) {
dbUpdate.advanced_weather_time_ms = data.advanced_weather_time_ms + update.delta_advanced_weather_time_ms;
}
if (update.delta_weather_info_time_ms) {
dbUpdate.weather_info_time_ms = data.weather_info_time_ms + update.delta_weather_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 @@ -10,6 +10,7 @@ export class SolarEclipse2024Data extends Model<InferAttributes<SolarEclipse2024
declare info_time_ms: CreationOptional<number>;
declare app_time_ms: CreationOptional<number>;
declare advanced_weather_time_ms: CreationOptional<number>;
declare weather_info_time_ms: CreationOptional<number>;
declare timestamp: CreationOptional<Date>;
}

Expand Down Expand Up @@ -57,6 +58,11 @@ export function initializeSolarEclipse2024DataModel(sequelize: Sequelize) {
allowNull: false,
defaultValue: 0
},
weather_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 @@ -8,6 +8,7 @@ CREATE TABLE SolarEclipse2024Data (
app_time_ms INT NOT NULL DEFAULT 0,
info_time_ms INT NOT NULL DEFAULT 0,
advanced_weather_time_ms INT NOT NULL DEFAULT 0,
weather_info_time_ms INT NOT NULL DEFAULT 0,
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

PRIMARY KEY(id),
Expand Down

0 comments on commit 7bf0b4f

Please sign in to comment.