Skip to content

Commit ef111bd

Browse files
authored
Revert "Begin to factor towards a single data collection (#75)" (#76)
This reverts commit 1c4cf21.
1 parent 1c4cf21 commit ef111bd

File tree

6 files changed

+139
-333
lines changed

6 files changed

+139
-333
lines changed

init_db.py

+43-64
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,62 @@
11
import pymongo
22

3-
from opensensor.db import get_open_sensor_db
3+
from opensensor.utils import get_open_sensor_db
44

55
# Script for creating the Time Series
66

77
db = get_open_sensor_db()
8-
# try:
9-
# db.create_collection(
10-
# "Temperature",
11-
# timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
12-
# )
13-
# except pymongo.errors.CollectionInvalid:
14-
# print("Temperature collection Already exists, skipping ...")
15-
#
16-
# try:
17-
# db.create_collection(
18-
# "Humidity",
19-
# timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
20-
# )
21-
# except pymongo.errors.CollectionInvalid:
22-
# print("Humidity collection Already exists, skipping ...")
23-
#
24-
# try:
25-
# db.create_collection(
26-
# "Pressure",
27-
# timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
28-
# )
29-
# except pymongo.errors.CollectionInvalid:
30-
# print("Pressure collection Already exists, skipping ...")
31-
#
32-
# try:
33-
# db.create_collection(
34-
# "Lux",
35-
# timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
36-
# )
37-
# except pymongo.errors.CollectionInvalid:
38-
# print("Lux collection Already exists, skipping ...")
39-
#
40-
# try:
41-
# db.create_collection(
42-
# "CO2",
43-
# timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
44-
# )
45-
# except pymongo.errors.CollectionInvalid:
46-
# print("CO2 collection Already exists, skipping ...")
47-
#
48-
# try:
49-
# db.create_collection(
50-
# "Moisture",
51-
# timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
52-
# )
53-
# except pymongo.errors.CollectionInvalid:
54-
# print("Moisture collection Already exists, skipping ...")
55-
#
56-
# try:
57-
# db.create_collection(
58-
# "pH",
59-
# timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
60-
# )
61-
# except pymongo.errors.CollectionInvalid:
62-
# print("pH collection Already exists, skipping ...")
8+
try:
9+
db.create_collection(
10+
"Temperature",
11+
timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
12+
)
13+
except pymongo.errors.CollectionInvalid:
14+
print("Temperature collection Already exists, skipping ...")
15+
16+
try:
17+
db.create_collection(
18+
"Humidity",
19+
timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
20+
)
21+
except pymongo.errors.CollectionInvalid:
22+
print("Humidity collection Already exists, skipping ...")
23+
24+
try:
25+
db.create_collection(
26+
"Pressure",
27+
timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
28+
)
29+
except pymongo.errors.CollectionInvalid:
30+
print("Pressure collection Already exists, skipping ...")
6331

6432
try:
6533
db.create_collection(
66-
"FreeTier",
34+
"Lux",
6735
timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
68-
# expireAfterSeconds=8000000,
6936
)
7037
except pymongo.errors.CollectionInvalid:
71-
print("FreeTier collection Already exists, skipping ...")
38+
print("Lux collection Already exists, skipping ...")
7239

40+
try:
41+
db.create_collection(
42+
"CO2",
43+
timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
44+
)
45+
except pymongo.errors.CollectionInvalid:
46+
print("CO2 collection Already exists, skipping ...")
7347

7448
try:
7549
db.create_collection(
76-
"Migration",
77-
# timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
78-
# expireAfterSeconds=8000000,
50+
"Moisture",
51+
timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
7952
)
80-
db.Migration.create_index([("migration_name", 1)], unique=True)
53+
except pymongo.errors.CollectionInvalid:
54+
print("Moisture collection Already exists, skipping ...")
8155

56+
try:
57+
db.create_collection(
58+
"pH",
59+
timeseries={"timeField": "timestamp", "metaField": "metadata", "granularity": "minutes"},
60+
)
8261
except pymongo.errors.CollectionInvalid:
83-
print("Migration collection Already exists, skipping ...")
62+
print("pH collection Already exists, skipping ...")

migrate_collections.py

-100
This file was deleted.

0 commit comments

Comments
 (0)