Skip to content

Commit 6275dbb

Browse files
committed
chore: better represent the options as not the defaults, they just are the options
1 parent e29a2fd commit 6275dbb

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

dataimporter/importer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from datetime import date, datetime
22
from functools import partial
3-
from itertools import groupby
43
from pathlib import Path
54
from typing import Iterable, List, Optional, Union
65

6+
from itertools import groupby
77
from splitgill.manager import SplitgillClient, SplitgillDatabase
88
from splitgill.model import Record
99
from splitgill.utils import partition, now
@@ -26,7 +26,7 @@
2626
from dataimporter.lib.config import Config
2727
from dataimporter.lib.dbs import Store
2828
from dataimporter.lib.model import SourceRecord
29-
from dataimporter.lib.options import DEFAULT_OPTIONS
29+
from dataimporter.lib.options import PARSING_OPTIONS
3030
from dataimporter.lib.view import View
3131

3232

@@ -305,7 +305,7 @@ def add_to_mongo(self, view_name: str, everything: bool = False) -> Optional[int
305305

306306
database.ingest(records, commit=False, modified_field="modified")
307307
# send the options anyway, even if there's no change to them
308-
database.update_options(DEFAULT_OPTIONS, commit=False)
308+
database.update_options(PARSING_OPTIONS, commit=False)
309309
committed = database.commit()
310310
# flush the queue as we've handled everything in it now
311311
view.flush()

dataimporter/lib/options.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from splitgill.indexing.options import ParsingOptionsBuilder
2+
from splitgill.diffing import SG_DATE_FORMATS
23

34
builder = ParsingOptionsBuilder()
45

@@ -13,20 +14,16 @@
1314
builder.with_false_value("false").with_false_value("no").with_false_value("n")
1415

1516
# date formats
16-
# some common basic formats
17+
# add the formats used by Splitgill itself allowing us to pickup datetime objects
18+
for fmt in SG_DATE_FORMATS:
19+
builder.with_date_format(fmt)
20+
# then add the formats we want to support (some of which will already be in the SG list)
21+
builder.with_date_format("%Y-%m")
1722
builder.with_date_format("%Y-%m-%d")
18-
# rfc 3339ish
1923
builder.with_date_format("%Y-%m-%dT%H:%M:%S")
2024
builder.with_date_format("%Y-%m-%dT%H:%M:%S.%f")
2125
builder.with_date_format("%Y-%m-%dT%H:%M:%S%z")
2226
builder.with_date_format("%Y-%m-%dT%H:%M:%S.%f%z")
23-
builder.with_date_format("%Y%m%dT%H%m%s")
24-
# same as the above, just with a space instead of the T separator
25-
builder.with_date_format("%Y-%m-%d %H:%M:%S")
26-
builder.with_date_format("%Y-%m-%d %H:%M:%S.%f")
27-
builder.with_date_format("%Y-%m-%d %H:%M:%S%z")
28-
builder.with_date_format("%Y-%m-%d %H:%M:%S.%f%z")
29-
builder.with_date_format("%Y%m%d %H%m%s")
3027

3128
# geo hints
3229
builder.with_geo_hint(
@@ -36,4 +33,4 @@
3633
16,
3734
)
3835

39-
DEFAULT_OPTIONS = builder.build()
36+
PARSING_OPTIONS = builder.build()

0 commit comments

Comments
 (0)