Skip to content

Commit 5daf8e0

Browse files
committed
fix: newest score journal on top
1 parent d568967 commit 5daf8e0

File tree

4 files changed

+100
-20
lines changed

4 files changed

+100
-20
lines changed

backend/internal/graph/api/score_journal.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ func (r *Resolver) getScoreJournal(ctx context.Context, projectID string, userID
107107
entries = rows[:requestedLimit]
108108
}
109109

110-
// If backward pagination, reverse the results
111-
if last != nil {
112-
for i, j := 0, len(entries)-1; i < j; i, j = i+1, j-1 {
113-
entries[i], entries[j] = entries[j], entries[i]
114-
}
115-
}
116-
117110
// Convert to GraphQL model
118111
modelEntries := make([]*model.ScoreJournal, len(entries))
119112
for i, entry := range entries {

frontend/app/api/generated.ts

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,30 @@ export type Consent = {
215215
body: MarkdownText;
216216
id: Scalars['ID']['output'];
217217
key: Scalars['String']['output'];
218+
managedBy?: Maybe<Scalars['String']['output']>;
219+
managementType: ConsentManagementType;
218220
publishedAt?: Maybe<Scalars['DateTime']['output']>;
219221
title: Scalars['String']['output'];
222+
url?: Maybe<Scalars['String']['output']>;
223+
userHistory: Array<UserConsentHistoryEntry>;
220224
version: Scalars['Int']['output'];
221225
};
222226

227+
export enum ConsentAction {
228+
Accepted = 'ACCEPTED',
229+
Rejected = 'REJECTED'
230+
}
231+
232+
export enum ConsentManagementType {
233+
Local = 'LOCAL',
234+
Remote = 'REMOTE'
235+
}
236+
223237
export type ConsentStatus = {
224238
__typename?: 'ConsentStatus';
225239
acceptedConsents: Array<UserConsent>;
226240
pendingConsents: Array<Consent>;
241+
rejectedConsents: Array<UserConsent>;
227242
};
228243

229244
export type CreateChallengeInput = {
@@ -529,6 +544,7 @@ export type Mutation = {
529544
publishChallenge: Challenge;
530545
recordStreakActivity: StreakAchievement;
531546
regenerateJoinCode: Team;
547+
rejectConsent: UserConsent;
532548
removeTeamMembers: Team;
533549
removeUserFromProject: User;
534550
revokeAchievement: Scalars['Boolean']['output'];
@@ -665,9 +681,12 @@ export type MutationCreateChallengeArgs = {
665681

666682
export type MutationCreateConsentArgs = {
667683
body: Scalars['String']['input'];
684+
isRemote?: InputMaybe<Scalars['Boolean']['input']>;
668685
key: Scalars['String']['input'];
686+
managedBy?: InputMaybe<Scalars['String']['input']>;
669687
publishedAt?: InputMaybe<Scalars['DateTime']['input']>;
670688
title: Scalars['String']['input'];
689+
url?: InputMaybe<Scalars['String']['input']>;
671690
};
672691

673692

@@ -818,6 +837,11 @@ export type MutationRegenerateJoinCodeArgs = {
818837
};
819838

820839

840+
export type MutationRejectConsentArgs = {
841+
consentId: Scalars['ID']['input'];
842+
};
843+
844+
821845
export type MutationRemoveTeamMembersArgs = {
822846
teamId: Scalars['ID']['input'];
823847
userIds: Array<Scalars['ID']['input']>;
@@ -895,6 +919,7 @@ export type MutationUpdateConsentArgs = {
895919
id: Scalars['ID']['input'];
896920
publishedAt?: InputMaybe<Scalars['DateTime']['input']>;
897921
title?: InputMaybe<Scalars['String']['input']>;
922+
url?: InputMaybe<Scalars['String']['input']>;
898923
};
899924

900925

@@ -1590,9 +1615,21 @@ export type UserConnection = {
15901615

15911616
export type UserConsent = {
15921617
__typename?: 'UserConsent';
1593-
acceptedAt: Scalars['DateTime']['output'];
1618+
action: ConsentAction;
1619+
actionDate: Scalars['DateTime']['output'];
1620+
consent: Consent;
1621+
id: Scalars['ID']['output'];
1622+
};
1623+
1624+
export type UserConsentHistoryEntry = {
1625+
__typename?: 'UserConsentHistoryEntry';
1626+
action: ConsentAction;
15941627
consent: Consent;
1628+
externalConsentId?: Maybe<Scalars['String']['output']>;
1629+
externalTimestamp?: Maybe<Scalars['DateTime']['output']>;
15951630
id: Scalars['ID']['output'];
1631+
occurredAt: Scalars['DateTime']['output'];
1632+
source?: Maybe<Scalars['String']['output']>;
15961633
};
15971634

15981635
export type UserEdge = {
@@ -1626,7 +1663,7 @@ export type ProjectRulesQueryVariables = Exact<{ [key: string]: never; }>;
16261663
export type ProjectRulesQuery = { __typename?: 'Query', myCurrentProject: { __typename?: 'Project', rules?: { __typename?: 'MarkdownText', markdown: string, html: string } | null } };
16271664

16281665
export type PointHistoryQueryVariables = Exact<{
1629-
first?: InputMaybe<Scalars['Int']['input']>;
1666+
last?: InputMaybe<Scalars['Int']['input']>;
16301667
}>;
16311668

16321669

@@ -2034,9 +2071,9 @@ export function useProjectRulesQuery(options?: Omit<Urql.UseQueryArgs<never, Pro
20342071
return Urql.useQuery<ProjectRulesQuery, ProjectRulesQueryVariables | undefined>({ query: ProjectRulesDocument, variables: undefined, ...options });
20352072
};
20362073
export const PointHistoryDocument = gql`
2037-
query PointHistory($first: Int) {
2074+
query PointHistory($last: Int) {
20382075
myCurrentProject {
2039-
journal(first: $first) {
2076+
journal(last: $last) {
20402077
edges {
20412078
node {
20422079
id
@@ -2056,6 +2093,22 @@ export const PointHistoryDocument = gql`
20562093
id
20572094
name
20582095
}
2096+
... on SimpleAchievement {
2097+
id
2098+
name
2099+
}
2100+
... on ReadingAchievement {
2101+
id
2102+
name
2103+
}
2104+
... on ListeningAchievement {
2105+
id
2106+
name
2107+
}
2108+
... on StreakAchievement {
2109+
id
2110+
name
2111+
}
20592112
}
20602113
points
20612114
createdAt

frontend/app/components/profile/ProfilePointHistory.vue

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
22
gql(`
3-
query PointHistory($first: Int) {
3+
query PointHistory($last: Int) {
44
myCurrentProject {
5-
journal(first: $first) {
5+
journal(last: $last) {
66
edges {
77
node {
88
id
@@ -22,6 +22,22 @@ gql(`
2222
id
2323
name
2424
}
25+
... on SimpleAchievement {
26+
id
27+
name
28+
}
29+
... on ReadingAchievement {
30+
id
31+
name
32+
}
33+
... on ListeningAchievement {
34+
id
35+
name
36+
}
37+
... on StreakAchievement {
38+
id
39+
name
40+
}
2541
}
2642
points
2743
createdAt
@@ -36,11 +52,13 @@ const open = ref(false)
3652
3753
const { isAuthReady } = useAuthReady()
3854
const { data, fetching, error } = usePointHistoryQuery({
39-
variables: { first: 100 },
55+
variables: { last: 100 },
4056
pause: computed(() => !isAuthReady.value || !open.value),
4157
})
4258
43-
function getScoreJournalName(journal: Partial<ScoreJournal>) {
59+
function getScoreJournalName(
60+
journal: PointHistoryQuery['myCurrentProject']['journal']['edges'][number]['node'],
61+
) {
4462
switch (journal.sourceType) {
4563
case ScoreSourceType.Achievement:
4664
return journal.source?.name

yaak-workspace/yaak.rq_KV7Pn2H44p.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ type: http_request
22
model: http_request
33
id: rq_KV7Pn2H44p
44
createdAt: 2025-11-27T13:05:40.352277
5-
updatedAt: 2025-12-02T10:16:56.479451
5+
updatedAt: 2025-12-03T09:19:48.602556
66
workspaceId: wk_XKsmbMdFg7
77
folderId: null
88
authentication: {}
@@ -11,11 +11,12 @@ body:
1111
query: |
1212
query ScoreJournal {
1313
myCurrentProject {
14-
journal(first: 100) {
14+
journal {
1515
edges {
1616
node {
1717
id
1818
sourceType
19+
reason
1920
source {
2021
__typename
2122
... on Achievement {
@@ -30,10 +31,25 @@ body:
3031
id
3132
name
3233
}
34+
... on SimpleAchievement {
35+
id
36+
name
37+
}
38+
... on ReadingAchievement {
39+
id
40+
name
41+
}
42+
... on ListeningAchievement {
43+
id
44+
name
45+
}
46+
... on StreakAchievement {
47+
id
48+
name
49+
}
3350
}
3451
points
3552
createdAt
36-
reason
3753
}
3854
}
3955
}
@@ -48,7 +64,7 @@ headers:
4864
value: application/json
4965
id: zNW4Vjp7UA
5066
method: POST
51-
name: ''
52-
sortPriority: 3000.0
67+
name: ScoreJournal
68+
sortPriority: 7000.0
5369
url: ${[ HOST ]}/graphql
5470
urlParameters: []

0 commit comments

Comments
 (0)