|
@@ -24,6 +24,7 @@ namespace molilian.core
|
|
|
private const int HourlyExpireSeconds = 7 * 86400; // keep a week of hourly buckets
|
|
private const int HourlyExpireSeconds = 7 * 86400; // keep a week of hourly buckets
|
|
|
private const string DefaultDimensionValue = "";
|
|
private const string DefaultDimensionValue = "";
|
|
|
private const int LinkCacheExpireSeconds = 30 * 86400;
|
|
private const int LinkCacheExpireSeconds = 30 * 86400;
|
|
|
|
|
+ private const string LinkCacheVersion = "v2";
|
|
|
private const string TrackRequestLogKey = ":tracks:request:logs";
|
|
private const string TrackRequestLogKey = ":tracks:request:logs";
|
|
|
private static readonly HashSet<string> SupportEventTypes = new(StringComparer.OrdinalIgnoreCase) { "expose", "click" };
|
|
private static readonly HashSet<string> SupportEventTypes = new(StringComparer.OrdinalIgnoreCase) { "expose", "click" };
|
|
|
|
|
|
|
@@ -224,6 +225,20 @@ namespace molilian.core
|
|
|
if (link != null) linkCache[trackId] = link;
|
|
if (link != null) linkCache[trackId] = link;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (link != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ string linkEventType = NormalizeEventType(link.event_type);
|
|
|
|
|
+ if (!SupportEventTypes.Contains(linkEventType)) continue;
|
|
|
|
|
+ if (!string.Equals(eventType, linkEventType, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
+ {
|
|
|
|
|
+ _ = new LoggerLibrary("TracksCore", "FlushDaily")
|
|
|
|
|
+ .Info($"skip stale track bucket: member={member}, link_event_type={linkEventType}", string.Empty)
|
|
|
|
|
+ .SaveAsync();
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ eventType = linkEventType;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
string reportScene = ResolveMetricScene(link, memberScene);
|
|
string reportScene = ResolveMetricScene(link, memberScene);
|
|
|
string bucketKey = BuildMetricIndexValue(eventType, trackId, reportScene, accountId);
|
|
string bucketKey = BuildMetricIndexValue(eventType, trackId, reportScene, accountId);
|
|
|
if (!buckets.TryGetValue(bucketKey, out var bucket))
|
|
if (!buckets.TryGetValue(bucketKey, out var bucket))
|
|
@@ -388,12 +403,12 @@ ON DUPLICATE KEY UPDATE
|
|
|
typename = Normalize(typename);
|
|
typename = Normalize(typename);
|
|
|
scene = NormalizeOrAll(scene);
|
|
scene = NormalizeOrAll(scene);
|
|
|
uniqueId = NormalizeOrAll(uniqueId);
|
|
uniqueId = NormalizeOrAll(uniqueId);
|
|
|
- return $"{RedisPrefix}:link:{eventType}:{platform}:{typename}:{scene}:{uniqueId}";
|
|
|
|
|
|
|
+ return $"{RedisPrefix}:cache:{LinkCacheVersion}:link:{eventType}:{platform}:{typename}:{scene}:{uniqueId}";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static string GetLinkIdCacheKey(int trackId)
|
|
public static string GetLinkIdCacheKey(int trackId)
|
|
|
{
|
|
{
|
|
|
- return $"{RedisPrefix}:linkid:{trackId}";
|
|
|
|
|
|
|
+ return $"{RedisPrefix}:cache:{LinkCacheVersion}:linkid:{trackId}";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static async Task<TrackLinkDTO> GetLinkByIdAsync(int trackId)
|
|
public static async Task<TrackLinkDTO> GetLinkByIdAsync(int trackId)
|