Skip to content
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

Add account details to queryStatuses #3236

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

matthieusieben
Copy link
Contributor

@matthieusieben matthieusieben commented Dec 12, 2024

  • Add support for pre-existing view indexes in the migration (allowing the views and indexes to be created manually instead of through the migration)
  • Refresh materialized views from the worker (note: refresh order matters!)
  • Determine which columns to expose as filter
    • For those: add an index on their respective materialized views
    • Adapt the code to support the filtering

@matthieusieben matthieusieben marked this pull request as draft December 12, 2024 16:07
@matthieusieben matthieusieben force-pushed the msi/ozone-subject-stats branch 2 times, most recently from 3a88fb1 to 9401fc2 Compare December 18, 2024 15:37
@matthieusieben matthieusieben force-pushed the msi/ozone-subject-stats branch from 7bbec5a to 3f7412c Compare January 10, 2025 13:40
@matthieusieben matthieusieben force-pushed the msi/ozone-subject-stats branch from d86cf08 to da81bb8 Compare January 10, 2025 13:47
}
},
"accountStats": {
"description": "Statistics about a particular account subject on the labeller",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, but generally we refer to these as "mod service" instead of labeler since it's duties are wider than just labeling. alternately, could just leave off the "on the labeler"

)
.execute()

// TODO try/catch to ignore existing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migrations are meant to be run once and nearly all of our migrations will fail if re-run (for instance createTable)

basically, i don't think you need to worry about a try/catch here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I manually created those view in the prod db. But Devin tells me that migrations are manually performed anyways so this does not matter indeed.

export const moderationSubjectStatusQueryBuilder = (db: DatabaseSchema) => {
return db
.selectFrom('moderation_subject_status as mss')
.selectAll('mss')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do get the appeal of the shortened versions of these table names, but they leak out into the calling functions and I find it hard to balance the mental state of them. Generally I try to only use abbreviated names like this when the variable is confined to some scoped function & the context is contained within a dozen or two lines. Even though it's wordier, I'm inclined to just use the table names for these.

@@ -312,19 +313,6 @@ export class ModerationService {
.executeTakeFirst()
}

async getCurrentStatus(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This work might just be in-progress, but I think this method is still needed. Specifically, I see it used in createReport

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mistake. will revert 👍


const builder = moderationSubjectStatusQueryBuilder(this.db.db).where(
(clause) => {
return parsedSubjects.reduce(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind've badass, and I'm a fan of using reduce in most places. But in the context of postgres subqueries, I lean more towards a straight-foward/imperative approach that makes it a bit easier to reason about.

I do really appreciate getting rid of the index check on this which i think is similarly unclear

Copy link
Contributor Author

@matthieusieben matthieusieben Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would use this pattern but that requires updating Kysely (which is non trivial).

But reading the docs of the current version we use, we can see:

Even the first where can be an orWhere. This is useful if you are looping through a set of conditions:

So we don't actually need the index check.

@matthieusieben matthieusieben marked this pull request as ready for review January 17, 2025 14:01
Copy link
Contributor

@foysalit foysalit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good!

packages/pds/src/index.ts Outdated Show resolved Hide resolved
const applySubjectFilter = filterForSubject(
subject.did,
subject.recordPath,
if (!subjects.length) return new Map()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! looks so much simpler!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants