-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Member enrichment llm lfx 1712 #2688
Open
themarolt
wants to merge
6
commits into
main
Choose a base branch
from
member-enrichment-llm-LFX-1712
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
Empty file.
50 changes: 50 additions & 0 deletions
50
backend/src/database/migrations/V1731052735__llm-prompt-history.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
create table "llmPromptHistory" ( | ||
id bigserial primary key, | ||
type varchar(255) not null, | ||
model text not null, | ||
"entityId" text null, | ||
metadata jsonb null, | ||
prompt text not null, | ||
answer text not null, | ||
"inputTokenCount" int not null, | ||
"outputTokenCount" int not null, | ||
"responseTimeSeconds" decimal not null, | ||
"createdAt" timestamptz not null default now() | ||
); | ||
|
||
create index "ix_llmPromptHistory_type_entityId" on "llmPromptHistory"("type", "entityId"); | ||
create index "ix_llmPromptHistory_entityId" on "llmPromptHistory"("entityId"); | ||
create index "ix_llmPromptHistory_type" on "llmPromptHistory"("type"); | ||
|
||
-- backup members table | ||
create table members_backup_14_11_2024 as | ||
select * | ||
from members | ||
with no data; | ||
|
||
-- Copy all data | ||
insert into members_backup_14_11_2024 | ||
select * | ||
from members; | ||
|
||
-- backup memberIdentities table | ||
create table member_identities_backup_14_11_2024 as | ||
select * | ||
from "memberIdentities" | ||
with no data; | ||
|
||
-- Copy all data | ||
insert into member_identities_backup_14_11_2024 | ||
select * | ||
from "memberIdentities"; | ||
|
||
-- backup memberOrganizations table | ||
create table member_organizations_backup_14_11_2024 as | ||
select * | ||
from "memberOrganizations" | ||
with no data; | ||
|
||
-- Copy all data | ||
insert into member_organizations_backup_14_11_2024 | ||
select * | ||
from "memberOrganizations"; | ||
Comment on lines
+19
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve backup strategy
+do $$
+declare
+ backup_date text := to_char(current_timestamp, 'DD_MM_YYYY');
+ members_count int;
+ member_identities_count int;
+ member_organizations_count int;
+begin
+ -- Get original counts
+ select count(*) into members_count from members;
+ select count(*) into member_identities_count from "memberIdentities";
+ select count(*) into member_organizations_count from "memberOrganizations";
+
-- backup members table
- create table members_backup_14_11_2024 as
+ execute format('create table members_backup_%s as
select *
from members
- with no data;
+ with no data', backup_date);
-- Copy all data
- insert into members_backup_14_11_2024
+ execute format('insert into members_backup_%s
select *
- from members;
+ from members', backup_date);
+ -- Validate backup
+ execute format('
+ if (select count(*) from members_backup_%s) != $1 then
+ raise exception ''Members backup validation failed'';
+ end if
+ ', backup_date) using members_count;
-- Similar changes for other tables...
+ -- Cleanup old backups (older than 30 days)
+ for backup_table in
+ select tablename
+ from pg_tables
+ where tablename like 'members_backup_%'
+ or tablename like 'member_identities_backup_%'
+ or tablename like 'member_organizations_backup_%'
+ loop
+ if to_date(right(backup_table, 10), 'DD_MM_YYYY') < current_date - interval '30 days' then
+ execute format('drop table if exists %I', backup_table);
+ end if;
+ end loop;
+end $$;
|
5 changes: 5 additions & 0 deletions
5
backend/src/database/migrations/V1731484783__drop-member-deprecated-columns.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
alter table members | ||
drop column "oldEmails"; | ||
|
||
alter table members | ||
drop column "oldWeakIdentities"; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider additional constraints and optimizations
type
column could be more efficient as an enum typemodel
column should have a CHECK constraint to validate allowed modelsmetadata
column should have validation to ensure JSON structure