Skip to content

Commit 7cf32d7

Browse files
committed
more vibe coding
1 parent 39fbe08 commit 7cf32d7

File tree

1 file changed

+9
-43
lines changed

1 file changed

+9
-43
lines changed

packages/node-sdk/src/summary-event.ts

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ export enum EventType {
66
CHECK = "check",
77
}
88

9-
/**
10-
* Represents an event entry with its values
11-
*/
12-
interface EventEntry {
13-
hasTrue: boolean;
14-
hasFalse: boolean;
15-
}
16-
179
/**
1810
* A simple bitset implementation for efficient boolean storage
1911
*/
@@ -84,15 +76,13 @@ export class SummaryEvent {
8476
// For each company and event type, we store:
8577
// 1. A bitset tracking true values
8678
// 2. A bitset tracking false values
87-
// 3. A bitset tracking which positions have been set
8879
private companies: Map<
8980
string,
9081
Map<
9182
EventType,
9283
{
9384
trueValues: BitSet;
9485
falseValues: BitSet;
95-
present: BitSet;
9686
}
9787
>
9888
>;
@@ -140,7 +130,6 @@ export class SummaryEvent {
140130
eventData = {
141131
trueValues: new BitSet(),
142132
falseValues: new BitSet(),
143-
present: new BitSet(),
144133
};
145134
companyEvents.set(eventType, eventData);
146135
}
@@ -151,9 +140,6 @@ export class SummaryEvent {
151140
} else {
152141
eventData.falseValues.set(featureKeyId, true);
153142
}
154-
155-
// Mark as present
156-
eventData.present.set(featureKeyId, true);
157143
}
158144

159145
/**
@@ -175,9 +161,9 @@ export class SummaryEvent {
175161
// Collect all feature IDs that are present in any event type
176162
const featureIds = new Set<number>();
177163
for (const eventData of companyEvents.values()) {
178-
// For each bit that is set in the 'present' bitset, add the feature ID
164+
// Check both true and false values bitsets
179165
for (let i = 0; i < this.featureKeyArray.length; i++) {
180-
if (eventData.present.isSet(i)) {
166+
if (eventData.trueValues.isSet(i) || eventData.falseValues.isSet(i)) {
181167
featureIds.add(i);
182168
}
183169
}
@@ -188,12 +174,13 @@ export class SummaryEvent {
188174
}
189175

190176
/**
191-
* Checks if an event exists for a given company, feature and event type
177+
* Checks if an event exists for a given company, feature, event type, and value
192178
*/
193179
public hasEvent(
194180
companyId: string,
195181
featureKey: string,
196182
eventType: EventType,
183+
value: boolean,
197184
): boolean {
198185
const featureKeyId = this.featureKeyMap.get(featureKey);
199186
if (featureKeyId === undefined) return false;
@@ -204,30 +191,9 @@ export class SummaryEvent {
204191
const eventData = companyEvents.get(eventType);
205192
if (!eventData) return false;
206193

207-
return eventData.present.isSet(featureKeyId);
208-
}
209-
210-
/**
211-
* Gets the event value for a specific company, feature and event type
212-
*/
213-
public getEventDetails(
214-
companyId: string,
215-
featureKey: string,
216-
eventType: EventType,
217-
): EventEntry | undefined {
218-
const featureKeyId = this.featureKeyMap.get(featureKey);
219-
if (featureKeyId === undefined) return undefined;
220-
221-
const companyEvents = this.companies.get(companyId);
222-
if (!companyEvents) return undefined;
223-
224-
const eventData = companyEvents.get(eventType);
225-
if (!eventData || !eventData.present.isSet(featureKeyId)) return undefined;
226-
227-
const hasTrue = eventData.trueValues.isSet(featureKeyId);
228-
const hasFalse = eventData.falseValues.isSet(featureKeyId);
229-
230-
return { hasTrue, hasFalse };
194+
return value
195+
? eventData.trueValues.isSet(featureKeyId)
196+
: eventData.falseValues.isSet(featureKeyId);
231197
}
232198

233199
/**
@@ -242,10 +208,10 @@ export class SummaryEvent {
242208

243209
for (const companyEvents of this.companies.values()) {
244210
for (const eventData of companyEvents.values()) {
245-
// Count set bits in the present bitset
211+
// Count features that have either true or false values
246212
let companyFeatureCount = 0;
247213
for (let i = 0; i < this.featureKeyArray.length; i++) {
248-
if (eventData.present.isSet(i)) {
214+
if (eventData.trueValues.isSet(i) || eventData.falseValues.isSet(i)) {
249215
companyFeatureCount++;
250216
}
251217
}

0 commit comments

Comments
 (0)