mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-31 12:39:01 +00:00
parent
1f49ea46b5
commit
67ea711319
@ -194,7 +194,7 @@ class OMetaTableMixin:
|
||||
:param table: Table Entity to update
|
||||
:param table_usage_request: Usage data to add
|
||||
"""
|
||||
resp = self.client.put(
|
||||
resp = self.client.post(
|
||||
f"/usage/table/{table.id.__root__}", data=table_usage_request.json()
|
||||
)
|
||||
logger.debug("published table usage %s", resp)
|
||||
|
@ -2263,16 +2263,19 @@ public interface CollectionDAO {
|
||||
+ "(:count1 + (SELECT COALESCE(SUM(count1), 0) FROM entity_usage WHERE id = :id AND usageDate >= :date - "
|
||||
+ "INTERVAL 6 DAY)), "
|
||||
+ "(:count1 + (SELECT COALESCE(SUM(count1), 0) FROM entity_usage WHERE id = :id AND usageDate >= :date - "
|
||||
+ "INTERVAL 29 DAY))",
|
||||
+ "INTERVAL 29 DAY))"
|
||||
+ "ON DUPLICATE KEY UPDATE count7 = count7 - count1 + :count1, count30 = count30 - count1 + :count1, count1 = :count1",
|
||||
connectionType = MYSQL)
|
||||
@ConnectionAwareSqlUpdate(
|
||||
value =
|
||||
"INSERT INTO entity_usage (usageDate, id, entityType, count1, count7, count30) "
|
||||
+ "SELECT (:date :: date), :id, :entityType, :count1, "
|
||||
+ "(:count1 + (SELECT COALESCE(SUM(count1), 0) FROM entity_usage WHERE id = :id AND usageDate >= (:date :: date) - INTERVAL '6 days')), "
|
||||
+ "(:count1 + (SELECT COALESCE(SUM(count1), 0) FROM entity_usage WHERE id = :id AND usageDate >= (:date :: date) - INTERVAL '29 days'))",
|
||||
+ "(:count1 + (SELECT COALESCE(SUM(count1), 0) FROM entity_usage WHERE id = :id AND usageDate >= (:date :: date) - INTERVAL '29 days'))"
|
||||
+ "ON CONFLICT (usageDate, id) DO UPDATE SET count7 = entity_usage.count7 - entity_usage.count1 + :count1,"
|
||||
+ "count30 = entity_usage.count30 - entity_usage.count1 + :count1, count1 = :count1",
|
||||
connectionType = POSTGRES)
|
||||
void insert(
|
||||
void insertOrReplaceCount(
|
||||
@Bind("date") String date,
|
||||
@Bind("id") String id,
|
||||
@Bind("entityType") String entityType,
|
||||
|
@ -190,7 +190,7 @@ public class UsageRepository {
|
||||
|
||||
private void insertToUsageRepository(String method, String entityId, String entityType, DailyCount usage) {
|
||||
if (method.equals(POST)) {
|
||||
dao.usageDAO().insert(usage.getDate(), entityId, entityType, usage.getCount());
|
||||
dao.usageDAO().insertOrReplaceCount(usage.getDate(), entityId, entityType, usage.getCount());
|
||||
} else if (method.equals(PUT)) {
|
||||
dao.usageDAO().insertOrUpdateCount(usage.getDate(), entityId, entityType, usage.getCount());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user