Skip to content

Commit 53650cd

Browse files
authored
Merge pull request #7 from StackExchange/sorting-questions-fix
chore: we'll now retrieve questions and tags by creationDate
2 parents df24144 + c719369 commit 53650cd

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

plugins/search-backend-module-stack-overflow-teams-collator/src/collators/StackOverflowQuestionsCollatorFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class StackOverflowQuestionsCollatorFactory
9999
// See https://api.stackexchange.com/docs/questions
100100
this.requestParams = {
101101
order: 'desc',
102-
sort: 'activity',
102+
sort: 'creation',
103103
...(options.requestParams ?? {}),
104104
};
105105
}

plugins/stack-overflow-teams-backend/src/api/createStackOverflowApi.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export const createStackOverflowApi = (baseUrl: string) => {
66
teamName?: string,
77
body?: any,
88
searchQuery?: string,
9-
pageSize?: number
9+
pageSize?: number,
10+
additionalParams?: Record<string, string>
1011
): Promise<T> => {
1112
let url = teamName
1213
? `${baseUrl}/v3/teams/${teamName}${endpoint}`
@@ -22,6 +23,12 @@ export const createStackOverflowApi = (baseUrl: string) => {
2223
queryParams.append('pageSize', pageSize.toString());
2324
}
2425

26+
if (additionalParams) {
27+
Object.entries(additionalParams).forEach(([key, value]) => {
28+
queryParams.append(key, value);
29+
});
30+
}
31+
2532
if (queryParams.toString()) {
2633
url += `?${queryParams.toString()}`;
2734
}
@@ -49,8 +56,8 @@ export const createStackOverflowApi = (baseUrl: string) => {
4956
};
5057

5158
return {
52-
GET: <T>(endpoint: string, authToken: string, teamName?: string) =>
53-
request<T>(endpoint, 'GET', authToken, teamName),
59+
GET: <T>(endpoint: string, authToken: string, teamName?: string, additionalParams?: Record<string, string>) =>
60+
request<T>(endpoint, 'GET', authToken, teamName, undefined, undefined, undefined, additionalParams),
5461

5562
POST: <T>(endpoint: string, body: any, authToken: string, teamName?: string) =>
5663
request<T>(endpoint, 'POST', authToken, teamName, body),

plugins/stack-overflow-teams-backend/src/services/StackOverflowService/createStackOverflowService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ export async function createStackOverflowService({
3535
return {
3636
// GET
3737
getQuestions: authToken =>
38-
api.GET<PaginatedResponse<Question>>('/questions', authToken, teamName),
38+
api.GET<PaginatedResponse<Question>>('/questions', authToken, teamName, { sort: 'creation', order: 'desc' }),
3939
getTags: authToken =>
40-
api.GET<PaginatedResponse<Tag>>('/tags', authToken, teamName),
40+
api.GET<PaginatedResponse<Tag>>('/tags', authToken, teamName, { sort: 'creationDate', order: 'desc'}),
4141
getUsers: authToken =>
4242
api.GET<PaginatedResponse<User>>('/users', authToken, teamName),
4343
getMe: authToken => api.GET<User>('/users/me', authToken, teamName),

plugins/stack-overflow-teams/src/components/StackOverflow/StackOverflowPosts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const StackOverflowQuestions = () => {
102102
const [baseUrl, setBaseUrl] = useState<string>('');
103103
const { data, loading, error } = useStackOverflowData('questions');
104104
const [searchTerm, setSearchTerm] = useState('');
105-
const [activeFilter, setActiveFilter] = useState<string | null>(null);
105+
const [activeFilter, setActiveFilter] = useState<string | null>('active');
106106
const [currentPage, setCurrentPage] = useState(0);
107107

108108
useEffect(() => {

0 commit comments

Comments
 (0)