You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@texera.apache.org by "jaeyun0503 (via GitHub)" <gi...@apache.org> on 2025/08/19 06:36:13 UTC
[PR] feat: add account creation time [texera]
jaeyun0503 opened a new pull request, #3675:
URL: https://github.com/apache/texera/pull/3675
## Summary
In effort to improve admin dashboard and allow admins to view account creation time, a new column `acc_creation` is introduced to the table `time_log`. This attribute is meant to store the timestamp of a user's account creation time and is a required column of the table. Also to make sure that the account creation time is logged when a user creates account, a trigger is introduced to the database.
Closes Issue #3673.
## For Developers
Please do the following steps to incorporate with new changes:
- Apply core/scripts/sql/updates/12.sql to your local postgres instance
---
The current design of this functionality is to use a trigger `trg_time_log_autocreate` that executes function `time_log_autocreate` to add new data row to `time_log` when a new entry is added to `user`. The user's uid and the current time stamp will be logged into the table and based on the design the account creation time should not be able to be modified.
Some SQL statements were also added to the sql files so that it gives the existing users the same timestamp as we do not have the information of the previous accounts' creation time.
Improvements in future PRs:
- Add time zone to the admin dashboard so the admin does not get confusion
- Change the name of the `time_log` table to fit the naming convention of tables
Screenshot:
<img width="509" height="359" alt="User Role" src="https://github.com/user-attachments/assets/4d393ad3-7bac-4b95-9d86-af2d54d22645" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add account creation time [texera]
Posted by "jaeyun0503 (via GitHub)" <gi...@apache.org>.
jaeyun0503 commented on code in PR #3675:
URL: https://github.com/apache/texera/pull/3675#discussion_r2286638939
##########
deployment/k8s/texera-helmchart/files/texera_ddl.sql:
##########
@@ -393,6 +393,28 @@ CREATE TABLE IF NOT EXISTS time_log
last_login TIMESTAMPTZ
);
+WITH ts AS (SELECT '2025-01-01 00:00:00-07'::timestamptz AS t)
+INSERT INTO time_log (uid, acc_creation)
+SELECT u.uid, ts.t
+FROM "user" u, ts
+ON CONFLICT (uid) DO NOTHING;
+
+CREATE OR REPLACE FUNCTION time_log_autocreate()
+RETURNS trigger AS $$
+BEGIN
+INSERT INTO time_log (uid, acc_creation)
+VALUES (NEW.uid, now())
+ON CONFLICT (uid) DO NOTHING;
+RETURN NEW;
+END
+$$ LANGUAGE plpgsql;
+
+DROP TRIGGER IF EXISTS trg_time_log_autocreate ON "user";
+CREATE TRIGGER trg_time_log_autocreate
Review Comment:
@aicam When a new user is entered into `user`, the trigger will make sure that it also adds the corresponding (uid, acc_creation) to the `time_log` table as I enforced the acc_creation column to be NOT NULL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add account creation time [texera]
Posted by "aicam (via GitHub)" <gi...@apache.org>.
aicam commented on code in PR #3675:
URL: https://github.com/apache/texera/pull/3675#discussion_r2285506717
##########
core/gui/src/app/common/service/user/auth.service.ts:
##########
@@ -154,7 +154,7 @@ export class AuthService {
googleId: this.jwtHelperService.decodeToken(token).googleId,
googleAvatar: this.jwtHelperService.decodeToken(token).googleAvatar,
role: role,
- comment: this.jwtHelperService.decodeToken(token).comment,
+ comment: this.jwtHelperService.decodeToken(token).comment
Review Comment:
This change is not needed
##########
core/gui/src/app/dashboard/component/admin/user/admin-user.component.ts:
##########
@@ -195,6 +195,13 @@ export class AdminUserComponent implements OnInit {
return Date.now() - lastMs < AdminUserComponent.ACTIVE_WINDOW;
}
+ getAccCreation(user: User): number {
+ if (!user.accCreation) {
+ return 0;
+ }
+ return user.accCreation * 1000;
Review Comment:
Is there anyway to do it using libraries instead of manually multiplying by 1000?
##########
deployment/k8s/texera-helmchart/files/texera_ddl.sql:
##########
@@ -393,6 +393,28 @@ CREATE TABLE IF NOT EXISTS time_log
last_login TIMESTAMPTZ
);
+WITH ts AS (SELECT '2025-01-01 00:00:00-07'::timestamptz AS t)
+INSERT INTO time_log (uid, acc_creation)
+SELECT u.uid, ts.t
+FROM "user" u, ts
+ON CONFLICT (uid) DO NOTHING;
+
+CREATE OR REPLACE FUNCTION time_log_autocreate()
+RETURNS trigger AS $$
+BEGIN
+INSERT INTO time_log (uid, acc_creation)
+VALUES (NEW.uid, now())
+ON CONFLICT (uid) DO NOTHING;
+RETURN NEW;
+END
+$$ LANGUAGE plpgsql;
+
+DROP TRIGGER IF EXISTS trg_time_log_autocreate ON "user";
+CREATE TRIGGER trg_time_log_autocreate
Review Comment:
What is the role of `trg_time_log_autocreate`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add account creation time [texera]
Posted by "aicam (via GitHub)" <gi...@apache.org>.
aicam commented on PR #3675:
URL: https://github.com/apache/texera/pull/3675#issuecomment-3203393369
@chenlica the PR looks good to me, I just had a minor comment about `acc_creation` name which I believe will be clear when the table name itself is renamed to something related (like `user_time_log`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add account creation time [texera]
Posted by "jaeyun0503 (via GitHub)" <gi...@apache.org>.
jaeyun0503 closed pull request #3675: feat: add account creation time
URL: https://github.com/apache/texera/pull/3675
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add account creation time [texera]
Posted by "jaeyun0503 (via GitHub)" <gi...@apache.org>.
jaeyun0503 commented on PR #3675:
URL: https://github.com/apache/texera/pull/3675#issuecomment-3199462834
@aicam @chenlica Requesting reviews
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add account creation time [texera]
Posted by "jaeyun0503 (via GitHub)" <gi...@apache.org>.
jaeyun0503 commented on code in PR #3675:
URL: https://github.com/apache/texera/pull/3675#discussion_r2286637094
##########
core/gui/src/app/dashboard/component/admin/user/admin-user.component.ts:
##########
@@ -195,6 +195,13 @@ export class AdminUserComponent implements OnInit {
return Date.now() - lastMs < AdminUserComponent.ACTIVE_WINDOW;
}
+ getAccCreation(user: User): number {
+ if (!user.accCreation) {
+ return 0;
+ }
+ return user.accCreation * 1000;
Review Comment:
@aicam Because this timestamp is in epoch seconds(ms), so multiplying by 1000 converts it into a regular timestamp.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org