@@ -49,26 +49,15 @@ export class DataAccessRead implements DataAccessTypes.IDataRead {
49
49
async getChannelsByTopic (
50
50
topic : string ,
51
51
updatedBetween ?: DataAccessTypes . ITimestampBoundaries | undefined ,
52
- page ?: number | undefined ,
53
- pageSize ?: number | undefined ,
54
52
) : Promise < DataAccessTypes . IReturnGetChannelsByTopic > {
55
- return this . getChannelsByMultipleTopics ( [ topic ] , updatedBetween , page , pageSize ) ;
53
+ return this . getChannelsByMultipleTopics ( [ topic ] , updatedBetween ) ;
56
54
}
57
55
58
56
async getChannelsByMultipleTopics (
59
57
topics : string [ ] ,
60
58
updatedBetween ?: DataAccessTypes . ITimestampBoundaries ,
61
- page ?: number ,
62
- pageSize ?: number ,
63
59
) : Promise < DataAccessTypes . IReturnGetChannelsByTopic > {
64
- // Validate pagination parameters
65
- if ( page !== undefined && page < 1 ) {
66
- throw new Error ( `Page number must be greater than or equal to 1, but it is ${ page } ` ) ;
67
- }
68
- if ( pageSize !== undefined && pageSize < 1 ) {
69
- throw new Error ( `Page size must be greater than 0, but it is ${ pageSize } ` ) ;
70
- }
71
-
60
+ const result = await this . storage . getTransactionsByTopics ( topics ) ;
72
61
const pending = this . pendingStore ?. findByTopics ( topics ) || [ ] ;
73
62
74
63
const pendingItems = pending . map ( ( item ) => ( {
@@ -84,33 +73,6 @@ export class DataAccessRead implements DataAccessTypes.IDataRead {
84
73
topics : item . topics || [ ] ,
85
74
} ) ) ;
86
75
87
- // Calculate adjusted pagination
88
- let adjustedPage = page ;
89
- let adjustedPageSize = pageSize ;
90
- let pendingItemsOnCurrentPage = 0 ;
91
- if ( page !== undefined && pageSize !== undefined ) {
92
- const totalPending = pendingItems . length ;
93
- const itemsPerPage = ( page - 1 ) * pageSize ;
94
-
95
- if ( totalPending > itemsPerPage ) {
96
- pendingItemsOnCurrentPage = Math . min ( totalPending - itemsPerPage , pageSize ) ;
97
- adjustedPageSize = pageSize - pendingItemsOnCurrentPage ;
98
- adjustedPage = 1 ;
99
- if ( adjustedPageSize === 0 ) {
100
- adjustedPageSize = 1 ;
101
- pendingItemsOnCurrentPage -- ;
102
- }
103
- } else {
104
- adjustedPage = page - Math . floor ( totalPending / pageSize ) ;
105
- }
106
- }
107
-
108
- const result = await this . storage . getTransactionsByTopics (
109
- topics ,
110
- adjustedPage ,
111
- adjustedPageSize ,
112
- ) ;
113
-
114
76
const transactions = result . transactions . concat ( ...pendingItems ) ;
115
77
116
78
// list of channels having at least one tx updated during the updatedBetween boundaries
@@ -138,17 +100,6 @@ export class DataAccessRead implements DataAccessTypes.IDataRead {
138
100
prev [ curr . channelId ] . push ( curr . hash ) ;
139
101
return prev ;
140
102
} , { } as Record < string , string [ ] > ) ,
141
- pagination :
142
- page && pageSize
143
- ? {
144
- total : result . transactions . length + pendingItems . length ,
145
- page,
146
- pageSize,
147
- hasMore :
148
- ( page - 1 ) * pageSize + filteredTxs . length - pendingItemsOnCurrentPage <
149
- result . transactions . length ,
150
- }
151
- : undefined ,
152
103
} ,
153
104
result : {
154
105
transactions : filteredTxs . reduce ( ( prev , curr ) => {
0 commit comments