Skip to content

Commit

Permalink
Merge pull request #109 from Carifio24/locations-name-consistency
Browse files Browse the repository at this point in the history
Rename text search locations field for better consistency
  • Loading branch information
Carifio24 authored Mar 22, 2024
2 parents 5262704 + 3ee16a1 commit ccf7543
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/stories/solar-eclipse-2024/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const SolarEclipse2024Entry = S.struct({
user_uuid: S.string,
user_selected_locations: LatLonArray,
cloud_cover_selected_locations: LatLonArray,
text_search_locations: LatLonArray,
text_search_selected_locations: LatLonArray,
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 }),
Expand All @@ -27,7 +27,7 @@ export const SolarEclipse2024Entry = S.struct({
export const SolarEclipse2024Update = S.struct({
user_selected_locations: S.optional(LatLonArray, { exact: true }),
cloud_cover_selected_locations: S.optional(LatLonArray, { exact: true }),
text_search_locations: S.optional(LatLonArray, { exact: true }),
text_search_selected_locations: S.optional(LatLonArray, { 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 }),
Expand All @@ -46,7 +46,7 @@ export async function submitSolarEclipse2024Data(data: SolarEclipse2024DataT): P
...data,
user_selected_locations_count: data.user_selected_locations.length,
cloud_cover_selected_locations_count: data.cloud_cover_selected_locations.length,
text_search_locations_count: data.text_search_locations.length,
text_search_selected_locations_count: data.text_search_selected_locations.length,
};

return SolarEclipse2024Data.upsert(dataWithCounts).then(([item, _]) => item);
Expand Down Expand Up @@ -78,10 +78,10 @@ export async function updateSolarEclipse2024Data(userUUID: string, update: Solar
dbUpdate.cloud_cover_selected_locations = selected;
dbUpdate.cloud_cover_selected_locations_count = selected.length;
}
if (update.text_search_locations) {
const selected = data.text_search_locations.concat(update.text_search_locations);
dbUpdate.text_search_locations = selected;
dbUpdate.text_search_locations_count = selected.length;
if (update.text_search_selected_locations) {
const selected = data.text_search_selected_locations.concat(update.text_search_selected_locations);
dbUpdate.text_search_selected_locations = selected;
dbUpdate.text_search_selected_locations_count = selected.length;
}
if (update.delta_info_time_ms) {
dbUpdate.info_time_ms = data.info_time_ms + update.delta_info_time_ms;
Expand Down
8 changes: 4 additions & 4 deletions src/stories/solar-eclipse-2024/models/eclipse_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export class SolarEclipse2024Data extends Model<InferAttributes<SolarEclipse2024
declare user_selected_locations_count: number;
declare cloud_cover_selected_locations: [number, number][];
declare cloud_cover_selected_locations_count: number;
declare text_search_locations: [number, number][];
declare text_search_locations_count: number;
declare text_search_selected_locations: [number, number][];
declare text_search_selected_locations_count: number;
declare info_time_ms: CreationOptional<number>;
declare app_time_ms: CreationOptional<number>;
declare advanced_weather_time_ms: CreationOptional<number>;
Expand Down Expand Up @@ -47,11 +47,11 @@ export function initializeSolarEclipse2024DataModel(sequelize: Sequelize) {
type: DataTypes.INTEGER,
allowNull: false
},
text_search_locations: {
text_search_selected_locations: {
type: DataTypes.JSON,
allowNull: false
},
text_search_locations_count: {
text_search_selected_locations_count: {
type: DataTypes.INTEGER,
allowNull: false
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ CREATE TABLE SolarEclipse2024Data (
user_selected_locations_count INT NOT NULL,
cloud_cover_selected_locations JSON NOT NULL,
cloud_cover_selected_locations_count INT NOT NULL,
text_search_locations JSON NOT NULL,
text_search_locations_count INT NOT NULL,
text_search_selected_locations JSON NOT NULL,
text_search_selected_locations_count INT NOT NULL,
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,
Expand Down

0 comments on commit ccf7543

Please sign in to comment.