Skip to content

Commit

Permalink
Remove access url
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed Sep 6, 2024
1 parent c949a2a commit ed30bc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 3 additions & 7 deletions apps/vpnmanager/src/lib/data/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface Record {
date: string;
cumulativeData: number;
email: string;
accessUrl?: string;
createdAt: string;
}

Expand All @@ -34,7 +33,6 @@ class Model {
date TEXT NOT NULL,
cumulativeData INTEGER NOT NULL,
email TEXT NOT NULL,
accessUrl TEXT,
createdAt TEXT NOT NULL,
UNIQUE (date, userId)
)
Expand All @@ -44,14 +42,13 @@ class Model {

static createOrUpdate(record: Record) {
const insertData = db.prepare(`
INSERT INTO records (userId, usage, date, cumulativeData, email, accessUrl, createdAt)
VALUES (?, ?, ?, ?, ?, ?, ?)
INSERT INTO records (userId, usage, date, cumulativeData, email, createdAt)
VALUES (?, ?, ?, ?, ?, ?)
ON CONFLICT(date, userId)
DO UPDATE SET
usage = excluded.usage,
cumulativeData = excluded.cumulativeData,
email = excluded.email,
accessUrl = excluded.accessUrl,
createdAt = excluded.createdAt;
`);
const info = insertData.run(
Expand All @@ -60,7 +57,6 @@ class Model {
record.date,
record.cumulativeData,
record.email,
record.accessUrl,
record.createdAt,
);
return { ...record, ID: info.lastInsertRowid };
Expand All @@ -86,7 +82,7 @@ class Model {
if (filters.groupBy === "email" || filters.groupBy === "date") {
query +=
filters.groupBy === "email"
? " email, userId, accessUrl, SUM(usage) as totalUsage FROM records"
? " email, userId, SUM(usage) as totalUsage FROM records"
: " date, SUM(usage) as totalUsage FROM records";
} else {
query += " * FROM records";
Expand Down
1 change: 0 additions & 1 deletion apps/vpnmanager/src/lib/userStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export async function processUserStats() {
date,
cumulativeData: bytesTransferredByUserId[key],
email: userDetails?.name || "",
accessUrl: userDetails?.accessUrl,
};
addUserStatsToDb({ ...newData, createdAt: new Date().toISOString() });
return newData;
Expand Down

0 comments on commit ed30bc7

Please sign in to comment.