Commit e781dd0718ea3b25f8a08ebf46fa2f60dac2f213
Committed by
GitHub
Merge pull request #1070 from ViktorBasanets/master
Merge
Showing
14 changed files
with
82 additions
and
54 deletions
... | ... | @@ -29,8 +29,8 @@ CREATE TABLE IF NOT EXISTS thingsboard.entity_views ( |
29 | 29 | customer_id timeuuid, |
30 | 30 | name text, |
31 | 31 | keys text, |
32 | - ts_begin bigint, | |
33 | - ts_end bigint, | |
32 | + start_ts bigint, | |
33 | + end_ts bigint, | |
34 | 34 | search_text text, |
35 | 35 | additional_info text, |
36 | 36 | PRIMARY KEY (id, entity_id, tenant_id, customer_id) |
... | ... | @@ -43,8 +43,8 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_na |
43 | 43 | AND tenant_id IS NOT NULL |
44 | 44 | AND customer_id IS NOT NULL |
45 | 45 | AND keys IS NOT NULL |
46 | - AND ts_begin IS NOT NULL | |
47 | - AND ts_end IS NOT NULL | |
46 | + AND start_ts IS NOT NULL | |
47 | + AND end_ts IS NOT NULL | |
48 | 48 | AND name IS NOT NULL |
49 | 49 | AND id IS NOT NULL |
50 | 50 | PRIMARY KEY (tenant_id, name, id, entity_id, customer_id) |
... | ... | @@ -57,8 +57,8 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_en |
57 | 57 | AND tenant_id IS NOT NULL |
58 | 58 | AND customer_id IS NOT NULL |
59 | 59 | AND keys IS NOT NULL |
60 | - AND ts_begin IS NOT NULL | |
61 | - AND ts_end IS NOT NULL | |
60 | + AND start_ts IS NOT NULL | |
61 | + AND end_ts IS NOT NULL | |
62 | 62 | AND name IS NOT NULL |
63 | 63 | AND id IS NOT NULL |
64 | 64 | PRIMARY KEY (tenant_id, entity_id, id, customer_id, name) |
... | ... | @@ -71,8 +71,8 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_cu |
71 | 71 | AND tenant_id IS NOT NULL |
72 | 72 | AND customer_id IS NOT NULL |
73 | 73 | AND keys IS NOT NULL |
74 | - AND ts_begin IS NOT NULL | |
75 | - AND ts_end IS NOT NULL | |
74 | + AND start_ts IS NOT NULL | |
75 | + AND end_ts IS NOT NULL | |
76 | 76 | AND name IS NOT NULL |
77 | 77 | AND id IS NOT NULL |
78 | 78 | PRIMARY KEY (tenant_id, customer_id, id, entity_id, name) |
... | ... | @@ -85,8 +85,8 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_cu |
85 | 85 | AND tenant_id IS NOT NULL |
86 | 86 | AND customer_id IS NOT NULL |
87 | 87 | AND keys IS NOT NULL |
88 | - AND ts_begin IS NOT NULL | |
89 | - AND ts_end IS NOT NULL | |
88 | + AND start_ts IS NOT NULL | |
89 | + AND end_ts IS NOT NULL | |
90 | 90 | AND name IS NOT NULL |
91 | 91 | AND id IS NOT NULL |
92 | 92 | PRIMARY KEY (tenant_id, customer_id, entity_id, id, name) | ... | ... |
... | ... | @@ -24,8 +24,8 @@ CREATE TABLE IF NOT EXISTS entity_views ( |
24 | 24 | customer_id varchar(31), |
25 | 25 | name varchar(255), |
26 | 26 | keys varchar(255), |
27 | - ts_begin varchar(255), | |
28 | - ts_end varchar(255), | |
27 | + start_ts bigint, | |
28 | + end_ts bigint, | |
29 | 29 | search_text varchar(255), |
30 | 30 | additional_info varchar |
31 | 31 | ); | ... | ... |
... | ... | @@ -29,10 +29,15 @@ import org.thingsboard.rule.engine.api.util.DonAsynchron; |
29 | 29 | import org.thingsboard.server.actors.service.ActorService; |
30 | 30 | import org.thingsboard.server.common.data.DataConstants; |
31 | 31 | import org.thingsboard.server.common.data.EntityType; |
32 | +import org.thingsboard.server.common.data.EntityView; | |
32 | 33 | import org.thingsboard.server.common.data.id.DeviceId; |
33 | 34 | import org.thingsboard.server.common.data.id.EntityId; |
34 | 35 | import org.thingsboard.server.common.data.id.EntityIdFactory; |
36 | +//<<<<<<< HEAD | |
37 | +import org.thingsboard.server.common.data.id.EntityViewId; | |
38 | +//======= | |
35 | 39 | import org.thingsboard.server.common.data.id.TenantId; |
40 | +//>>>>>>> d909192071880b7af2137333142bc62ece369ec1 | |
36 | 41 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
37 | 42 | import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
38 | 43 | import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; |
... | ... | @@ -48,6 +53,8 @@ import org.thingsboard.server.common.data.kv.TsKvEntry; |
48 | 53 | import org.thingsboard.server.common.msg.cluster.SendToClusterMsg; |
49 | 54 | import org.thingsboard.server.common.msg.cluster.ServerAddress; |
50 | 55 | import org.thingsboard.server.dao.attributes.AttributesService; |
56 | +import org.thingsboard.server.dao.entityview.EntityViewService; | |
57 | +import org.thingsboard.server.dao.model.ModelConstants; | |
51 | 58 | import org.thingsboard.server.dao.timeseries.TimeseriesService; |
52 | 59 | import org.thingsboard.server.gen.cluster.ClusterAPIProtos; |
53 | 60 | import org.thingsboard.server.service.cluster.routing.ClusterRoutingService; |
... | ... | @@ -101,6 +108,9 @@ public class DefaultTelemetrySubscriptionService implements TelemetrySubscriptio |
101 | 108 | @Autowired |
102 | 109 | private ClusterRpcService rpcService; |
103 | 110 | |
111 | + /*@Autowired | |
112 | + private EntityViewService entityViewService;*/ | |
113 | + | |
104 | 114 | @Autowired |
105 | 115 | @Lazy |
106 | 116 | private DeviceStateService stateService; |
... | ... | @@ -133,15 +143,17 @@ public class DefaultTelemetrySubscriptionService implements TelemetrySubscriptio |
133 | 143 | |
134 | 144 | @Override |
135 | 145 | public void addLocalWsSubscription(String sessionId, EntityId entityId, SubscriptionState sub) { |
146 | + String familyName = entityId.getEntityType().equals(EntityType.ENTITY_VIEW) | |
147 | + ? ModelConstants.ENTITY_VIEW_FAMILY_NAME : ModelConstants.DEVICE_FAMILY_NAME; | |
136 | 148 | Optional<ServerAddress> server = routingService.resolveById(entityId); |
137 | 149 | Subscription subscription; |
138 | 150 | if (server.isPresent()) { |
139 | 151 | ServerAddress address = server.get(); |
140 | - log.trace("[{}] Forwarding subscription [{}] for device [{}] to [{}]", sessionId, sub.getSubscriptionId(), entityId, address); | |
152 | + log.trace("[{}] Forwarding subscription [{}] for " + familyName + " [{}] to [{}]", sessionId, sub.getSubscriptionId(), entityId, address); | |
141 | 153 | subscription = new Subscription(sub, true, address); |
142 | 154 | tellNewSubscription(address, sessionId, subscription); |
143 | 155 | } else { |
144 | - log.trace("[{}] Registering local subscription [{}] for device [{}]", sessionId, sub.getSubscriptionId(), entityId); | |
156 | + log.trace("[{}] Registering local subscription [{}] for " + familyName + " [{}]", sessionId, sub.getSubscriptionId(), entityId); | |
145 | 157 | subscription = new Subscription(sub, true); |
146 | 158 | } |
147 | 159 | registerSubscription(sessionId, entityId, subscription); | ... | ... |
... | ... | @@ -30,9 +30,15 @@ public class Subscription { |
30 | 30 | private final SubscriptionState sub; |
31 | 31 | private final boolean local; |
32 | 32 | private ServerAddress server; |
33 | + private long startTime; | |
34 | + private long endTime; | |
33 | 35 | |
34 | 36 | public Subscription(SubscriptionState sub, boolean local) { |
35 | - this(sub, local, null); | |
37 | + this(sub, local, null, 0L, 0L); | |
38 | + } | |
39 | + | |
40 | + public Subscription(SubscriptionState sub, boolean local, ServerAddress server) { | |
41 | + this(sub, local, server, 0L, 0L); | |
36 | 42 | } |
37 | 43 | |
38 | 44 | public String getWsSessionId() { | ... | ... |
... | ... | @@ -24,7 +24,7 @@ import java.util.Arrays; |
24 | 24 | |
25 | 25 | @RunWith(ClasspathSuite.class) |
26 | 26 | @ClasspathSuite.ClassnameFilters({ |
27 | - "org.thingsboard.server.controller.sql.*Test", | |
27 | + "org.thingsboard.server.controller.sql.EntityViewControllerSqlTest", | |
28 | 28 | }) |
29 | 29 | public class ControllerSqlTestSuite { |
30 | 30 | ... | ... |
... | ... | @@ -42,4 +42,8 @@ public class BaseReadTsKvQuery extends BaseTsKvQuery implements ReadTsKvQuery { |
42 | 42 | this(key, startTs, endTs, endTs - startTs, 1, Aggregation.AVG, "DESC"); |
43 | 43 | } |
44 | 44 | |
45 | + public BaseReadTsKvQuery(String key, long startTs, long endTs, int limit, String orderBy) { | |
46 | + this(key, startTs, endTs, endTs - startTs, limit, Aggregation.AVG, orderBy); | |
47 | + } | |
48 | + | |
45 | 49 | } | ... | ... |
... | ... | @@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
24 | 24 | import org.springframework.cache.Cache; |
25 | 25 | import org.springframework.cache.CacheManager; |
26 | 26 | import org.springframework.cache.annotation.CacheEvict; |
27 | +import org.springframework.cache.annotation.CachePut; | |
27 | 28 | import org.springframework.cache.annotation.Cacheable; |
28 | 29 | import org.springframework.stereotype.Service; |
29 | 30 | import org.thingsboard.server.common.data.Customer; |
... | ... | @@ -88,7 +89,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
88 | 89 | @Autowired |
89 | 90 | private CacheManager cacheManager; |
90 | 91 | |
91 | -// @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}") | |
92 | + @Cacheable(cacheNames = ENTITY_VIEW_CACHE) | |
92 | 93 | @Override |
93 | 94 | public EntityView findEntityViewById(EntityViewId entityViewId) { |
94 | 95 | log.trace("Executing findEntityViewById [{}]", entityViewId); |
... | ... | @@ -104,7 +105,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
104 | 105 | .orElse(null); |
105 | 106 | } |
106 | 107 | |
107 | -// @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityView.id}") | |
108 | + @CachePut(cacheNames = ENTITY_VIEW_CACHE) | |
108 | 109 | @Override |
109 | 110 | public EntityView saveEntityView(EntityView entityView) { |
110 | 111 | log.trace("Executing save entity view [{}]", entityView); |
... | ... | @@ -136,7 +137,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
136 | 137 | List<Object> list = new ArrayList<>(); |
137 | 138 | list.add(entityView.getTenantId()); |
138 | 139 | list.add(entityView.getName()); |
139 | -// cache.evict(list); | |
140 | + cache.evict(list); | |
140 | 141 | entityViewDao.removeById(entityViewId.getId()); |
141 | 142 | } |
142 | 143 | |
... | ... | @@ -149,7 +150,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
149 | 150 | return new TextPageData<>(entityViews, pageLink); |
150 | 151 | } |
151 | 152 | |
152 | -// @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#tenantId, #entityId, #pageLink}") | |
153 | + @Cacheable(cacheNames = ENTITY_VIEW_CACHE) | |
153 | 154 | @Override |
154 | 155 | public TextPageData<EntityView> findEntityViewByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, |
155 | 156 | TextPageLink pageLink) { |
... | ... | @@ -189,7 +190,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
189 | 190 | return new TextPageData<>(entityViews, pageLink); |
190 | 191 | } |
191 | 192 | |
192 | -// @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#tenantId, #customerId, #entityId, #pageLink}") | |
193 | + @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#tenantId, #customerId, #entityId, #pageLink}") | |
193 | 194 | @Override |
194 | 195 | public TextPageData<EntityView> findEntityViewsByTenantIdAndCustomerIdAndEntityId(TenantId tenantId, |
195 | 196 | CustomerId customerId, | ... | ... |
... | ... | @@ -131,6 +131,7 @@ public class ModelConstants { |
131 | 131 | * Cassandra device constants. |
132 | 132 | */ |
133 | 133 | public static final String DEVICE_COLUMN_FAMILY_NAME = "device"; |
134 | + public static final String DEVICE_FAMILY_NAME = "device"; | |
134 | 135 | public static final String DEVICE_TENANT_ID_PROPERTY = TENANT_ID_PROPERTY; |
135 | 136 | public static final String DEVICE_CUSTOMER_ID_PROPERTY = CUSTOMER_ID_PROPERTY; |
136 | 137 | public static final String DEVICE_NAME_PROPERTY = "name"; |
... | ... | @@ -147,6 +148,7 @@ public class ModelConstants { |
147 | 148 | * Cassandra entityView constants. |
148 | 149 | */ |
149 | 150 | public static final String ENTITY_VIEW_TABLE_FAMILY_NAME = "entity_views"; |
151 | + public static final String ENTITY_VIEW_FAMILY_NAME = "entity-view"; | |
150 | 152 | public static final String ENTITY_VIEW_ENTITY_ID_PROPERTY = ENTITY_ID_COLUMN; |
151 | 153 | public static final String ENTITY_VIEW_TENANT_ID_PROPERTY = TENANT_ID_PROPERTY; |
152 | 154 | public static final String ENTITY_VIEW_CUSTOMER_ID_PROPERTY = CUSTOMER_ID_PROPERTY; |
... | ... | @@ -154,8 +156,8 @@ public class ModelConstants { |
154 | 156 | public static final String ENTITY_VIEW_TYPE_PROPERTY = DEVICE_TYPE_PROPERTY; |
155 | 157 | public static final String ENTITY_VIEW_TENANT_AND_NAME_VIEW_NAME = "entity_view_by_tenant_and_name"; |
156 | 158 | public static final String ENTITY_VIEW_KEYS_PROPERTY = "keys"; |
157 | - public static final String ENTITY_VIEW_TS_BEGIN_PROPERTY = "ts_begin"; | |
158 | - public static final String ENTITY_VIEW_TS_END_PROPERTY = "ts_end"; | |
159 | + public static final String ENTITY_VIEW_START_TS_PROPERTY = "start_ts"; | |
160 | + public static final String ENTITY_VIEW_END_TS_PROPERTY = "end_ts"; | |
159 | 161 | public static final String ENTITY_VIEW_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY; |
160 | 162 | public static final String ENTITY_VIEW_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "entity_view_by_tenant_and_search_text"; |
161 | 163 | ... | ... |
... | ... | @@ -75,11 +75,11 @@ public class EntityViewEntity implements SearchTextEntity<EntityView> { |
75 | 75 | @Column(name = ModelConstants.ENTITY_VIEW_KEYS_PROPERTY) |
76 | 76 | private String keys; |
77 | 77 | |
78 | - @Column(name = ModelConstants.ENTITY_VIEW_TS_BEGIN_PROPERTY) | |
79 | - private String tsBegin; | |
78 | + @Column(name = ModelConstants.ENTITY_VIEW_START_TS_PROPERTY) | |
79 | + private long startTs; | |
80 | 80 | |
81 | - @Column(name = ModelConstants.ENTITY_VIEW_TS_END_PROPERTY) | |
82 | - private String tsEnd; | |
81 | + @Column(name = ModelConstants.ENTITY_VIEW_END_TS_PROPERTY) | |
82 | + private long endTs; | |
83 | 83 | |
84 | 84 | @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
85 | 85 | private String searchText; |
... | ... | @@ -114,8 +114,8 @@ public class EntityViewEntity implements SearchTextEntity<EntityView> { |
114 | 114 | } catch (IOException e) { |
115 | 115 | e.printStackTrace(); |
116 | 116 | } |
117 | - this.tsBegin = entityView.getStartTs() != 0L ? String.valueOf(entityView.getStartTs()) : "0"; | |
118 | - this.tsEnd = entityView.getEndTs() != 0L ? String.valueOf(entityView.getEndTs()) : "0"; | |
117 | + this.startTs = entityView.getStartTs() != 0L ? entityView.getStartTs() : 0L; | |
118 | + this.endTs = entityView.getEndTs() != 0L ? entityView.getEndTs() : 0L; | |
119 | 119 | this.searchText = entityView.getSearchText(); |
120 | 120 | this.additionalInfo = entityView.getAdditionalInfo(); |
121 | 121 | } |
... | ... | @@ -144,8 +144,8 @@ public class EntityViewEntity implements SearchTextEntity<EntityView> { |
144 | 144 | } catch (IOException e) { |
145 | 145 | e.printStackTrace(); |
146 | 146 | } |
147 | - entityView.setStartTs(Long.parseLong(tsBegin)); | |
148 | - entityView.setEndTs(Long.parseLong(tsEnd)); | |
147 | + entityView.setStartTs(startTs); | |
148 | + entityView.setEndTs(endTs); | |
149 | 149 | entityView.setAdditionalInfo(additionalInfo); |
150 | 150 | return entityView; |
151 | 151 | } | ... | ... |
... | ... | @@ -66,11 +66,11 @@ public class EntityViewEntity extends BaseSqlEntity<EntityView> implements Searc |
66 | 66 | @Column(name = ModelConstants.ENTITY_VIEW_KEYS_PROPERTY) |
67 | 67 | private String keys; |
68 | 68 | |
69 | - @Column(name = ModelConstants.ENTITY_VIEW_TS_BEGIN_PROPERTY) | |
70 | - private String tsBegin; | |
69 | + @Column(name = ModelConstants.ENTITY_VIEW_START_TS_PROPERTY) | |
70 | + private long startTs; | |
71 | 71 | |
72 | - @Column(name = ModelConstants.ENTITY_VIEW_TS_END_PROPERTY) | |
73 | - private String tsEnd; | |
72 | + @Column(name = ModelConstants.ENTITY_VIEW_END_TS_PROPERTY) | |
73 | + private long endTs; | |
74 | 74 | |
75 | 75 | @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
76 | 76 | private String searchText; |
... | ... | @@ -105,8 +105,8 @@ public class EntityViewEntity extends BaseSqlEntity<EntityView> implements Searc |
105 | 105 | } catch (IOException e) { |
106 | 106 | e.printStackTrace(); |
107 | 107 | } |
108 | - this.tsBegin = entityView.getStartTs() != 0L ? String.valueOf(entityView.getStartTs()) : "0"; | |
109 | - this.tsEnd = entityView.getEndTs() != 0L ? String.valueOf(entityView.getEndTs()) : "0"; | |
108 | + this.startTs = entityView.getStartTs() != 0L ? entityView.getStartTs() : 0L; | |
109 | + this.endTs = entityView.getEndTs() != 0L ? entityView.getEndTs() : 0L; | |
110 | 110 | this.searchText = entityView.getSearchText(); |
111 | 111 | this.additionalInfo = entityView.getAdditionalInfo(); |
112 | 112 | } |
... | ... | @@ -141,8 +141,8 @@ public class EntityViewEntity extends BaseSqlEntity<EntityView> implements Searc |
141 | 141 | } catch (IOException e) { |
142 | 142 | e.printStackTrace(); |
143 | 143 | } |
144 | - entityView.setStartTs(Long.parseLong(tsBegin)); | |
145 | - entityView.setEndTs(Long.parseLong(tsEnd)); | |
144 | + entityView.setStartTs(startTs); | |
145 | + entityView.setEndTs(endTs); | |
146 | 146 | entityView.setAdditionalInfo(additionalInfo); |
147 | 147 | return entityView; |
148 | 148 | } | ... | ... |
... | ... | @@ -71,13 +71,17 @@ public class BaseTimeseriesService implements TimeseriesService { |
71 | 71 | validate(entityId); |
72 | 72 | List<ListenableFuture<TsKvEntry>> futures = Lists.newArrayListWithExpectedSize(keys.size()); |
73 | 73 | keys.forEach(key -> Validator.validateString(key, "Incorrect key " + key)); |
74 | - if (false/*entityId.getEntityType().equals(EntityType.ENTITY_VIEW)*/) { | |
74 | + if (entityId.getEntityType().equals(EntityType.ENTITY_VIEW)) { | |
75 | 75 | EntityView entityView = entityViewService.findEntityViewById((EntityViewId) entityId); |
76 | - Collection<String> newKeys = chooseKeysForEntityView(entityView, keys); | |
77 | - newKeys.forEach(newKey -> futures.add(timeseriesDao.findLatest(entityView.getEntityId(), newKey))); | |
78 | - } else { | |
79 | - keys.forEach(key -> futures.add(timeseriesDao.findLatest(entityId, key))); | |
76 | + Collection<String> matchingKeys = chooseKeysForEntityView(entityView, keys); | |
77 | + List<ReadTsKvQuery> queries = new ArrayList<>(); | |
78 | + | |
79 | + matchingKeys.forEach(key -> queries.add( | |
80 | + new BaseReadTsKvQuery(key, entityView.getStartTs(), entityView.getEndTs(), 1, "ASC"))); | |
81 | + | |
82 | + return timeseriesDao.findAllAsync(entityView.getEntityId(), updateQueriesForEntityView(entityView, queries)); | |
80 | 83 | } |
84 | + keys.forEach(key -> futures.add(timeseriesDao.findLatest(entityId, key))); | |
81 | 85 | return Futures.allAsList(futures); |
82 | 86 | } |
83 | 87 | |
... | ... | @@ -150,7 +154,6 @@ public class BaseTimeseriesService implements TimeseriesService { |
150 | 154 | return newQueries; |
151 | 155 | } |
152 | 156 | |
153 | - @Deprecated /*Will be a modified*/ | |
154 | 157 | private Collection<String> chooseKeysForEntityView(EntityView entityView, Collection<String> keys) { |
155 | 158 | Collection<String> newKeys = new ArrayList<>(); |
156 | 159 | entityView.getKeys().getTimeseries() | ... | ... |
... | ... | @@ -647,8 +647,8 @@ CREATE TABLE IF NOT EXISTS thingsboard.entity_views ( |
647 | 647 | customer_id timeuuid, |
648 | 648 | name text, |
649 | 649 | keys text, |
650 | - ts_begin bigint, | |
651 | - ts_end bigint, | |
650 | + start_ts bigint, | |
651 | + end_ts bigint, | |
652 | 652 | search_text text, |
653 | 653 | additional_info text, |
654 | 654 | PRIMARY KEY (id, tenant_id, customer_id) |
... | ... | @@ -657,27 +657,27 @@ CREATE TABLE IF NOT EXISTS thingsboard.entity_views ( |
657 | 657 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_name AS |
658 | 658 | SELECT * |
659 | 659 | from thingsboard.entity_views |
660 | - WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND ts_begin IS NOT NULL AND ts_end IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL | |
660 | + WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL | |
661 | 661 | PRIMARY KEY (tenant_id, name, id, entity_id, customer_id) |
662 | 662 | WITH CLUSTERING ORDER BY (name ASC, id DESC, entity_id DESC, customer_id DESC); |
663 | 663 | |
664 | 664 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_entity AS |
665 | 665 | SELECT * |
666 | 666 | from thingsboard.entity_views |
667 | - WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND ts_begin IS NOT NULL AND ts_end IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL | |
667 | + WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL | |
668 | 668 | PRIMARY KEY (tenant_id, entity_id, id, customer_id, name) |
669 | 669 | WITH CLUSTERING ORDER BY (entity_id ASC, customer_id ASC, id DESC, name DESC); |
670 | 670 | |
671 | 671 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer AS |
672 | 672 | SELECT * |
673 | 673 | from thingsboard.entity_views |
674 | - WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND ts_begin IS NOT NULL AND ts_end IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL | |
674 | + WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL | |
675 | 675 | PRIMARY KEY (tenant_id, customer_id, id, entity_id, name) |
676 | 676 | WITH CLUSTERING ORDER BY (customer_id ASC, id DESC, entity_id DESC, name DESC); |
677 | 677 | |
678 | 678 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_entity AS |
679 | 679 | SELECT * |
680 | 680 | from thingsboard.entity_views |
681 | - WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND ts_begin IS NOT NULL AND ts_end IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL | |
681 | + WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL | |
682 | 682 | PRIMARY KEY (tenant_id, customer_id, entity_id, id, name) |
683 | 683 | WITH CLUSTERING ORDER BY (customer_id ASC, entity_id DESC, id DESC, name DESC); | ... | ... |
... | ... | @@ -260,8 +260,8 @@ CREATE TABLE IF NOT EXISTS entity_views ( |
260 | 260 | customer_id varchar(31), |
261 | 261 | name varchar(255), |
262 | 262 | keys varchar(255), |
263 | - ts_begin varchar(255), | |
264 | - ts_end varchar(255), | |
263 | + start_ts bigint, | |
264 | + end_ts bigint, | |
265 | 265 | search_text varchar(255), |
266 | 266 | additional_info varchar |
267 | 267 | ); | ... | ... |