Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove source field from tooth.json #19

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.8.0] - 2024-02-03

### Changed

- Remove `source` field from `tooth.json`.

## [0.7.0] - 2024-01-19

Expand Down Expand Up @@ -71,7 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Basic functionality.

[unreleased]: https://github.com/lippkg/lip-index/compare/v0.7.0...HEAD
[0.8.0]: https://github.com/lippkg/lip-index/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/lippkg/lip-index/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/lippkg/lip-index/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/lippkg/lip-index/compare/v0.4.0...v0.5.0
Expand Down
7 changes: 3 additions & 4 deletions lib/github_bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async function fetchVersion(
throw new Error(`failed to fetch metadata: ${err.message}`);
});

const sourceRepoInfo = await getRepository(octokit, repoOwner, repoName);
const repoInfo = await getRepository(octokit, repoOwner, repoName);

await toothVersionModel.upsert({
repoOwner,
Expand All @@ -150,9 +150,8 @@ async function fetchVersion(
author: metadata.author,
tags: metadata.tags,
avatarUrl: metadata.avatarUrl,
source: metadata.source,
sourceRepoCreatedAt: sourceRepoInfo.createdAt,
sourceRepoStarCount: sourceRepoInfo.starCount,
repoCreatedAt: repoInfo.createdAt,
starCount: repoInfo.starCount,
updatedAt: new Date(),
});

Expand Down
4 changes: 0 additions & 4 deletions lib/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export class Metadata {
get avatarUrl(): string|undefined {
return this.raw.info.avatar_url;
}

get source(): string {
return this.raw.info.source ?? this.raw.tooth;
}
}

function validateRawMetadata(raw: RawMetadata) {
Expand Down
1 change: 0 additions & 1 deletion lib/rawmetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ export interface RawMetadata {
info: {
name: string; description: string; author: string; tags: string[];
avatar_url?: string;
source?: string;
}
}
3 changes: 1 addition & 2 deletions lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const JSON_SCHEMA = {
'type': 'array',
'items': {'type': 'string', 'pattern': '^[a-zA-Z0-9-]+$'}
},
'avatar_url': {'type': 'string'},
'source': {'type': 'string'}
'avatar_url': {'type': 'string'}
},
'required': ['name', 'description', 'author', 'tags']
},
Expand Down
13 changes: 4 additions & 9 deletions models/tooth_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ export class ToothVersionModel extends Model<
declare author: string;
declare tags: string[];
declare avatarUrl: string|null;
declare source: string;

declare sourceRepoCreatedAt: Date;
declare sourceRepoStarCount: number;
declare repoCreatedAt: Date;
declare starCount: number;

declare updatedAt: Date;
}
Expand Down Expand Up @@ -65,15 +64,11 @@ export function createToothVersionModel(sequelize: Sequelize):
avatarUrl: {
type: DataTypes.STRING,
},
source: {
type: DataTypes.STRING,
allowNull: false,
},
sourceRepoCreatedAt: {
repoCreatedAt: {
type: DataTypes.DATE,
allowNull: false,
},
sourceRepoStarCount: {
starCount: {
type: DataTypes.INTEGER,
allowNull: false,
},
Expand Down
11 changes: 5 additions & 6 deletions routes/search/teeth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const ORDER_MAP = {
};

const SORT_MAP = {
starCount: 'sourceRepoStarCount',
createdAt: 'sourceRepoCreatedAt',
starCount: 'starCount',
createdAt: 'repoCreatedAt',
updatedAt: 'releasedAt',
};

Expand Down Expand Up @@ -55,7 +55,7 @@ router.get(
...params.queryList.map(
(_, index) => ({
[sequelize.Op.like]: sequelize.literal(
`CONCAT("repoOwner", ' ', "repoName", ' ', name, ' ', description, ' ', author, ' ', array_to_string(tags, ' '), ' ', source) ILIKE :searchTerm${
`CONCAT("repoOwner", ' ', "repoName", ' ', name, ' ', description, ' ', author, ' ', array_to_string(tags, ' ')) ILIKE :searchTerm${
index}`),
})),
{
Expand Down Expand Up @@ -91,9 +91,8 @@ router.get(
author: item.author,
tags: item.tags,
avatarUrl: item.avatarUrl,
source: item.source,
sourceRepoCreatedAt: item.sourceRepoCreatedAt.toISOString(),
sourceRepoStarCount: item.sourceRepoStarCount,
repoCreatedAt: item.repoCreatedAt.toISOString(),
starCount: item.starCount,
})),
},
});
Expand Down
5 changes: 2 additions & 3 deletions routes/teeth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ router.get(
author: item.author,
tags: item.tags,
avatarUrl: item.avatarUrl,
source: item.source,
sourceRepoCreatedAt: item.sourceRepoCreatedAt.toISOString(),
sourceRepoStarCount: item.sourceRepoStarCount,
repoCreatedAt: item.repoCreatedAt.toISOString(),
starCount: item.starCount,
versions:
versions.map((version) => ({
version: version.version.version,
Expand Down
Loading