Skip to content

Commit

Permalink
feat: add ability for upload config to specify dat-first preference f…
Browse files Browse the repository at this point in the history
…or ambiguous date strings
  • Loading branch information
dennisgsmith committed Nov 20, 2024
1 parent bc0baab commit 309d12a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions api/internal/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions api/internal/db/uploader.sql_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/internal/service/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func timeseriesMeasurementCreateBatchFromCSVFile(ctx context.Context, q *db.Quer

up, err := upload.NewUpload(upload.UploadOpts{
FieldNameTimeseriesIDMap: fieldNameTimeseriesIDMap,
PreferDayFirst: uc.PreferDayFirst,
Timezone: uc.TzName,
ColOffset: int(uc.ColumnOffset),
RowOffset: int(uc.RowOffset),
Expand Down Expand Up @@ -249,6 +250,7 @@ func timeseriesMeasurementCreateBatchFromXLSXFile(ctx context.Context, q *db.Que

up, err := upload.NewUpload(upload.UploadOpts{
FieldNameTimeseriesIDMap: fieldNameTimeseriesIDMap,
PreferDayFirst: uc.PreferDayFirst,
Timezone: uc.TzName,
ColOffset: int(uc.ColumnOffset),
RowOffset: int(uc.RowOffset),
Expand Down
3 changes: 2 additions & 1 deletion api/migrations/repeat/0170__views_uploader.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ CREATE VIEW v_uploader_config AS (
u.depth_based_instrument_id,
u.instrument_field_enabled,
u.instrument_field,
u.xlsx_sheet_name
u.xlsx_sheet_name,
u.prefer_day_first
FROM uploader_config u
INNER JOIN profile pc ON u.created_by = pc.id
LEFT JOIN profile pu ON u.updated_by = pu.id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE uploader_config ADD column prefer_day_first boolean NOT NULL DEFAULT false;
9 changes: 6 additions & 3 deletions api/queries/uploader.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ insert into uploader_config (
depth_based_instrument_id,
instrument_field_enabled,
instrument_field,
xlsx_sheet_name
xlsx_sheet_name,
prefer_day_first
)
values (
sqlc.arg(project_id),
Expand All @@ -51,7 +52,8 @@ values (
sqlc.narg(depth_based_instrument_id),
sqlc.arg(instrument_field_enabled),
sqlc.narg(instrument_field),
sqlc.narg(xlsx_sheet_name)
sqlc.narg(xlsx_sheet_name),
sqlc.arg(prefer_day_first)
)
returning id;

Expand All @@ -76,7 +78,8 @@ update uploader_config set
depth_based_instrument_id=$17,
instrument_field_enabled=$18,
instrument_field=$19,
xlsx_sheet_name=$20
xlsx_sheet_name=$20,
prefer_day_first=$21
where id=$1;


Expand Down

0 comments on commit 309d12a

Please sign in to comment.