Skip to content

Conversation

@andresgutgon
Copy link
Contributor

@andresgutgon andresgutgon commented Oct 23, 2025

What?

Implement base files for issue models

TODO

  • Repository
  • Base services for creation
  • Factories
  • Implement issues SQL filtering
  • Make back navigation work from the middle. direction=backward Implemented page/offset finally
  • Sort by relevance DESC hardcoded for now. No UI
  • Labels on title for escalating warning and new accent no icons
  • Put Seen at 11d ago / 3yr old
  • Change size of tab selector. Make normal default and small without fancy layer and 32px max like a normal button.
  • Regressed: it has histogram items after being resolved.
  • Toggle by active/regressed/archived
  • Implement document change selector filter
  • When only one date is selected means Last seen up to ...
  • Implement search by title input

@andresgutgon andresgutgon force-pushed the feature/issues-plumbing branch 9 times, most recently from c08e609 to d4630fa Compare October 30, 2025 11:21
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 monster query deserves tests. However, I won't be doing that in this PR, so I want to move on to another thing. Anyway this is not yet released

@andresgutgon andresgutgon force-pushed the feature/issues-plumbing branch from d4630fa to 70b99c2 Compare October 30, 2025 11:31
@andresgutgon andresgutgon requested a review from neoxelox October 30, 2025 11:31
@andresgutgon andresgutgon force-pushed the feature/issues-plumbing branch from 70b99c2 to b946a8a Compare October 30, 2025 11:48
@andresgutgon andresgutgon changed the title Add issues related plumbing files for testing and shit Initial issues dashboard with filters Oct 30, 2025
/**
* SWR cache key for issues list based on filters and sorting
*/
export function buildIssuesCacheKey({
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more simpler if you just add the query string to the SWR cache key.... look how eval results v2 store work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll keep this way for now

const status = filters.status ?? serverParams.filters.status
const showStatus = status !== 'active'

if (noData) return <TableBlankSlate description='No issues in this project' />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (noData) return <TableBlankSlate description='No issues in this project' />
if (noData) return <TableBlankSlate description='No issues found for this prompt yet' />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could be for all prompts if no document is selected

}: {
workspace: Workspace
project: Project
documentUuid: string
Copy link
Contributor

Choose a reason for hiding this comment

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

why not pass the document 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.

I'll change when I use it in the next PR

},
transaction = new Transaction(),
) {
return transaction.call(async (tx) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should publish an issueCreated event maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same

`,
)
.as('recentCount'),
lastSeenDate: sql<Date>`MAX(${issueHistograms.date})`.as(
Copy link
Contributor

Choose a reason for hiding this comment

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

you need firstSeenDat with MIN on issueHistograms.date. That should be the first seen at date for the issue!

),
})
.from(issueHistograms)
.where(
Copy link
Contributor

Choose a reason for hiding this comment

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

this where is lacking the filter on date by the seenAt range date no?

inArray(issueHistograms.commitId, commitIds),
),
)
.groupBy(issueHistograms.issueId)
Copy link
Contributor

Choose a reason for hiding this comment

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

add a having that checks if the total count > 0

}

if (filters.firstSeen) {
conditions.push(gte(issues.createdAt, filters.firstSeen))
Copy link
Contributor

Choose a reason for hiding this comment

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

no, you should use the firstSeenAt of the subquery

Copy link
Contributor

Choose a reason for hiding this comment

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

Also you should compare the last seen issue date to the first seen of the range calendar.

)
}

if (filters.lastSeen) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is lacking the first seenAt

Copy link
Contributor

Choose a reason for hiding this comment

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

Also you should compare the first seen issue date to the last seen of the range calendar.

if (filters.lastSeen) {
const toEndOfDay = endOfDay(filters.lastSeen)
const condition = sql`${sql.raw(`"${HISTOGRAM_SUBQUERY_ALIAS}"."lastSeenDate"`)} <= ${toEndOfDay}`
if (condition) conditions.push(condition)
Copy link
Contributor

Choose a reason for hiding this comment

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

why this if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make typescript happy

* Returns the common GROUP BY clause fields for issues queries with histogram subquery.
* This includes all issue fields and subquery fields that are selected in the main query.
*/
private buildGroupByClause(
Copy link
Contributor

Choose a reason for hiding this comment

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

this group by is useless because you are just selecting all columns of the table... do a normal select no?

.leftJoin(subquery, eq(subquery.issueId, issues.id))
.where(and(...whereConditions))
.groupBy(...this.buildGroupByClause(subquery))
.having(
Copy link
Contributor

Choose a reason for hiding this comment

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

this having should be a where no?

.from(issues)
.leftJoin(subquery, eq(subquery.issueId, issues.id))
.where(and(...whereConditions))
.groupBy(...this.buildGroupByClause(subquery))
Copy link
Contributor

Choose a reason for hiding this comment

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

why group by?

.from(issues)
.leftJoin(subquery, eq(subquery.issueId, issues.id))
.where(and(...where))
.groupBy(...this.buildGroupByClause(subquery))
Copy link
Contributor

Choose a reason for hiding this comment

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

why group by

.leftJoin(subquery, eq(subquery.issueId, issues.id))
.where(and(...where))
.groupBy(...this.buildGroupByClause(subquery))
.having(having.length > 0 ? and(...having) : undefined)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be a where no?

Copy link
Contributor

@neoxelox neoxelox left a comment

Choose a reason for hiding this comment

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

review the main queries

@andresgutgon andresgutgon force-pushed the feature/issues-plumbing branch from d9e6c63 to 6575397 Compare October 31, 2025 08:49
@andresgutgon
Copy link
Contributor Author

review the main queries

I tried moving lastSeenAt and firstSeenAt to the subquery. But it did not work because you can not reference the subquery alias in the where of the subquery. We can review later

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