Skip to content

Commit 16d5e65

Browse files
feat(cat-voices): database queries migration and optimization (#3614)
* docs: capture initial times * chore: remove cacheDocument * turn off logging * chore: use debugPrint instead of logger * feat: bulk documents save * batching sync * chore: move exact ref resoling to getDocumentData instead of index * fix: DocumentRepository * chore: simplify getting documents data * remove getAllDocumentsRefs and getCachedDocumentsRefs from DocumentRepository. Index is only available in DocumentDataRemoteSource * chore: update docs * simplified document index endpoint * remove randomness from LocalCatGateway * indexing by batch size * wip: filtering by types * Rework filtering refs + checking all refs if already cached in parallel * docs * update indexing.csv * update indexing csv * chore: cleanup * trailing new line * chore * move performance tab to docs * bulk saving typed docs in parallel * chore: revert hardcoded timestamp * chore: typos * split _sync into smaller functions + add documentation * little refactor * fix: analyzer * initial v2 tables * wip * wip * feat: database migration * chore: cleanup * bump batch size * cleanup * chore: remove defensive content decoding * chore: daos * spelling * saveAll * test on platform * chore: update build scripts * feat: DocumentsV2Dao methods * simple proposals pagination query * chore: create a JoinedProposalBriefEntity * rename method * feat: exclude hidden proposals * more tests * renaming and splitting logic into smaller parts * feat: per language strategy * remove CatalystDatabaseLanguage in favor of raw queries as they are easier to mange * remove Index Strategy Documentation * handle case where ref is empty * migration now includes indexes * use v2 documents table for saveAll and isCachedBulk * adds ActionType to JoinedProposalBriefEntity * adds versionIds to JoinedProposalBriefEntity * comments count * adds isFavorite to JoinedProposalBriefEntity * add template to JoinedProposalBriefEntity * adds documentsLocalMetadata table for auto updates * Update docs * use v2 proposals query for discovery most recent section * feat: simplify most recent proposals section * add proposal fav status for v2 tables * local proposal fav status update * update fav state locally for faster feedback * self review * fix tests * update times * fix: analyzer * more migration test data * clean up constructors * cleanup * fix: template tests * spelling * fix: spelling * chore: PR review adjustments * fix: add discovery specific colors (#3637) * fix code-generator earthly target * use logger in migration + wrap in transaction --------- Co-authored-by: Ryszard Schossler <[email protected]>
1 parent a54ab8d commit 16d5e65

File tree

40 files changed

+4742
-640
lines changed

40 files changed

+4742
-640
lines changed

.config/dictionaries/project.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ Utxos
392392
uuidv
393393
varint
394394
Vespr
395+
vers
395396
vite
396397
vitss
397398
vkey

catalyst_voices/apps/voices/lib/pages/discovery/sections/campaign_hero.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import 'package:catalyst_voices/common/ext/build_context_ext.dart';
12
import 'package:catalyst_voices/routes/routing/spaces_route.dart';
23
import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart';
34
import 'package:catalyst_voices/widgets/buttons/voices_outlined_button.dart';
45
import 'package:catalyst_voices/widgets/heroes/section_hero.dart';
56
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
67
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
7-
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
88
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
99
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
1010
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart';
@@ -54,15 +54,15 @@ class _CampaignBrief extends StatelessWidget {
5454
key: const Key('CampaignBriefTitle'),
5555
context.l10n.heroSectionTitle,
5656
style: Theme.of(context).textTheme.displaySmall?.copyWith(
57-
color: ThemeBuilder.buildTheme().colorScheme.primary,
57+
color: context.colors.discoveryPrimary,
5858
),
5959
),
6060
const SizedBox(height: 32),
6161
Text(
6262
key: const Key('CampaignBriefDescription'),
6363
context.l10n.projectCatalystDescription,
6464
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
65-
color: ThemeBuilder.buildTheme().colors.textOnPrimaryLevel0,
65+
color: context.colors.discoveryTextOnPrimary,
6666
),
6767
),
6868
const SizedBox(height: 32),
@@ -74,8 +74,8 @@ class _CampaignBrief extends StatelessWidget {
7474
const ProposalsRoute().go(context);
7575
},
7676
style: FilledButton.styleFrom(
77-
backgroundColor: ThemeBuilder.buildTheme().colorScheme.primary,
78-
foregroundColor: ThemeBuilder.buildTheme().colorScheme.onPrimary,
77+
backgroundColor: context.colors.discoveryPrimary,
78+
foregroundColor: context.colors.discoveryOnPrimary,
7979
),
8080
child: Text(context.l10n.viewProposals),
8181
),
@@ -103,8 +103,8 @@ class _DiscoveryMyProposalsButton extends StatelessWidget {
103103
const WorkspaceRoute().go(context);
104104
},
105105
style: OutlinedButton.styleFrom(
106-
backgroundColor: ThemeBuilder.buildTheme().colorScheme.primary,
107-
foregroundColor: ThemeBuilder.buildTheme().colorScheme.onPrimary,
106+
backgroundColor: context.colors.discoveryPrimary,
107+
foregroundColor: context.colors.discoveryOnPrimary,
108108
),
109109
child: Text(context.l10n.myProposals),
110110
),
Lines changed: 3 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,12 @@
1-
import 'package:catalyst_voices/pages/discovery/sections/most_recent_proposals/recent_proposals.dart';
2-
import 'package:catalyst_voices/widgets/indicators/voices_error_indicator.dart';
3-
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
4-
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
1+
import 'package:catalyst_voices/pages/discovery/sections/most_recent_proposals/widgets/most_recent_offstage.dart';
2+
import 'package:catalyst_voices/pages/discovery/sections/most_recent_proposals/widgets/recent_proposals.dart';
53
import 'package:flutter/material.dart';
64

75
class MostRecentProposals extends StatelessWidget {
86
const MostRecentProposals({super.key});
97

108
@override
119
Widget build(BuildContext context) {
12-
return BlocSelector<DiscoveryCubit, DiscoveryState, DiscoveryMostRecentProposalsState>(
13-
selector: (state) => state.proposals,
14-
builder: (context, state) {
15-
return _MostRecentProposals(data: state);
16-
},
17-
);
18-
}
19-
}
20-
21-
class _MostRecentProposals extends StatelessWidget {
22-
final DiscoveryMostRecentProposalsState data;
23-
const _MostRecentProposals({
24-
required this.data,
25-
});
26-
27-
@override
28-
Widget build(BuildContext context) {
29-
return Stack(
30-
children: [
31-
_MostRecentProposalsError(data),
32-
_ViewAllProposals(
33-
offstage: data.showError || !data.hasMinProposalsToShow,
34-
),
35-
_MostRecentProposalsData(
36-
data,
37-
minProposalsToShow: data.hasMinProposalsToShow,
38-
),
39-
],
40-
);
41-
}
42-
}
43-
44-
class _MostRecentProposalsData extends StatelessWidget {
45-
final DiscoveryMostRecentProposalsState state;
46-
final bool minProposalsToShow;
47-
48-
const _MostRecentProposalsData(this.state, {this.minProposalsToShow = false});
49-
50-
@override
51-
Widget build(BuildContext context) {
52-
return Offstage(
53-
key: const Key('MostRecentProposalsData'),
54-
offstage: state.showError || !minProposalsToShow,
55-
child: RecentProposals(proposals: state.proposals),
56-
);
57-
}
58-
}
59-
60-
class _MostRecentProposalsError extends StatelessWidget {
61-
final DiscoveryMostRecentProposalsState state;
62-
63-
const _MostRecentProposalsError(this.state);
64-
65-
@override
66-
Widget build(BuildContext context) {
67-
final errorMessage = state.error?.message(context);
68-
return Offstage(
69-
key: const Key('MostRecentError'),
70-
offstage: !state.showError,
71-
child: Padding(
72-
padding: const EdgeInsets.all(16),
73-
child: Center(
74-
child: VoicesErrorIndicator(
75-
message: errorMessage ?? context.l10n.somethingWentWrong,
76-
onRetry: () async {
77-
await context.read<DiscoveryCubit>().getMostRecentProposals();
78-
},
79-
),
80-
),
81-
),
82-
);
83-
}
84-
}
85-
86-
class _ViewAllProposals extends StatelessWidget {
87-
final bool offstage;
88-
89-
const _ViewAllProposals({this.offstage = true});
90-
91-
@override
92-
Widget build(BuildContext context) {
93-
return Offstage(
94-
key: const Key('MostRecentProposalsData'),
95-
offstage: !offstage,
96-
child: const ViewAllProposals(),
97-
);
10+
return const MostRecentOffstage(child: RecentProposals());
9811
}
9912
}

0 commit comments

Comments
 (0)