Skip to content

Commit

Permalink
feat: Default to fork:true for extra classroom search (#436)
Browse files Browse the repository at this point in the history
* feat: Extra search option for GitHub Classroom

* feat: Default extraSearch to fork:true

* style(frontend): Fix lint problems
  • Loading branch information
Clashsoft authored Nov 14, 2024
1 parent b903038 commit 1727bcf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<label class="form-label" for="extraSearchQuery">Extra Search Options</label>
<div class="input-group">
<span class="input-group-text">org:{{classroom.org}} "{{classroom.prefix}}-" in:name</span>
<input type="text" class="form-control" id="extraSearchQuery" placeholder=""
<input type="text" class="form-control" id="extraSearchQuery" placeholder="fork:true"
[(ngModel)]="classroom.extraSearch" (change)="context.saveDraft()">
<button class="btn btn-outline-secondary bi-github" (click)="previewSearch()">
Preview
Expand All @@ -33,6 +33,7 @@
Extra GitHub search options to filter the repositories.
See <a href="https://docs.github.com/en/search-github/github-code-search/understanding-github-code-search-syntax" target="_blank">
GitHub Search Syntax</a>.
Default: <code>fork:true</code> to include forks.
Example: <code>fork:only archived:false</code>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class ClassroomComponent {
}

previewSearch() {
let url = new URL(`https://github.com/search`);
const url = new URL(`https://github.com/search`);
url.searchParams.set('type', 'repositories');
url.searchParams.set('q', `org:${this.classroom.org} "${this.classroom.prefix}-" in:name ${this.classroom.extraSearch || ''}`);
url.searchParams.set('q', `org:${this.classroom.org} "${this.classroom.prefix}-" in:name ${this.classroom.extraSearch ?? 'fork:true'}`);
open(url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class ClassroomService {

private getQuery(assignment: AssignmentDocument): string {
const {org, prefix, extraSearch} = assignment.classroom!;
return `org:${org} "${prefix}-" in:name ${extraSearch || ''}`;
return `org:${org} "${prefix}-" in:name ${extraSearch || 'fork:true'}`;
}

private async getRepoZip(assignment: AssignmentDocument, github: string, commit: string): Promise<Stream | undefined> {
Expand Down

0 comments on commit 1727bcf

Please sign in to comment.