mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	delete needless instance drive columns
This commit is contained in:
		
							parent
							
								
									ec64b5ea0b
								
							
						
					
					
						commit
						513c83e374
					
				
					 7 changed files with 13 additions and 30 deletions
				
			
		| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
export class removeInstanceDriveColumns1646655454495 {
 | 
			
		||||
    name = 'removeInstanceDriveColumns1646655454495'
 | 
			
		||||
 | 
			
		||||
    async up(queryRunner) {
 | 
			
		||||
        await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "driveUsage"`);
 | 
			
		||||
        await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "driveFiles"`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async down(queryRunner) {
 | 
			
		||||
        await queryRunner.query(`ALTER TABLE "instance" ADD "driveFiles" integer NOT NULL DEFAULT '0'`);
 | 
			
		||||
        await queryRunner.query(`ALTER TABLE "instance" ADD "driveUsage" bigint NOT NULL DEFAULT '0'`);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -59,22 +59,6 @@ export class Instance {
 | 
			
		|||
	})
 | 
			
		||||
	public followersCount: number;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * ドライブ使用量
 | 
			
		||||
	 */
 | 
			
		||||
	@Column('bigint', {
 | 
			
		||||
		default: 0,
 | 
			
		||||
	})
 | 
			
		||||
	public driveUsage: number;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * ドライブのファイル数
 | 
			
		||||
	 */
 | 
			
		||||
	@Column('integer', {
 | 
			
		||||
		default: 0,
 | 
			
		||||
	})
 | 
			
		||||
	public driveFiles: number;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 直近のリクエスト送信日時
 | 
			
		||||
	 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,10 +55,6 @@ export default define(meta, paramDef, async (ps, me) => {
 | 
			
		|||
		case '-caughtAt': query.orderBy('instance.caughtAt', 'ASC'); break;
 | 
			
		||||
		case '+lastCommunicatedAt': query.orderBy('instance.lastCommunicatedAt', 'DESC'); break;
 | 
			
		||||
		case '-lastCommunicatedAt': query.orderBy('instance.lastCommunicatedAt', 'ASC'); break;
 | 
			
		||||
		case '+driveUsage': query.orderBy('instance.driveUsage', 'DESC'); break;
 | 
			
		||||
		case '-driveUsage': query.orderBy('instance.driveUsage', 'ASC'); break;
 | 
			
		||||
		case '+driveFiles': query.orderBy('instance.driveFiles', 'DESC'); break;
 | 
			
		||||
		case '-driveFiles': query.orderBy('instance.driveFiles', 'ASC'); break;
 | 
			
		||||
 | 
			
		||||
		default: query.orderBy('instance.id', 'DESC'); break;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,14 +21,12 @@ export default class InstanceChart extends Chart<typeof schema> {
 | 
			
		|||
			followingCount,
 | 
			
		||||
			followersCount,
 | 
			
		||||
			driveFiles,
 | 
			
		||||
			//driveUsage,
 | 
			
		||||
		] = await Promise.all([
 | 
			
		||||
			Notes.count({ userHost: group }),
 | 
			
		||||
			Users.count({ host: group }),
 | 
			
		||||
			Followings.count({ followerHost: group }),
 | 
			
		||||
			Followings.count({ followeeHost: group }),
 | 
			
		||||
			DriveFiles.count({ userHost: group }),
 | 
			
		||||
			//DriveFiles.calcDriveUsageOfHost(group),
 | 
			
		||||
		]);
 | 
			
		||||
 | 
			
		||||
		return {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -484,8 +484,6 @@ export async function addFile({
 | 
			
		|||
	perUserDriveChart.update(file, true);
 | 
			
		||||
	if (file.userHost !== null) {
 | 
			
		||||
		instanceChart.updateDrive(file, true);
 | 
			
		||||
		Instances.increment({ host: file.userHost }, 'driveUsage', file.size);
 | 
			
		||||
		Instances.increment({ host: file.userHost }, 'driveFiles', 1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return file;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,8 +86,6 @@ async function postProcess(file: DriveFile, isExpired = false) {
 | 
			
		|||
	perUserDriveChart.update(file, false);
 | 
			
		||||
	if (file.userHost !== null) {
 | 
			
		||||
		instanceChart.updateDrive(file, false);
 | 
			
		||||
		Instances.decrement({ host: file.userHost }, 'driveUsage', file.size);
 | 
			
		||||
		Instances.decrement({ host: file.userHost }, 'driveFiles', 1);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,10 +33,6 @@
 | 
			
		|||
					<option value="-caughtAt">{{ $ts.registeredAt }} ({{ $ts.ascendingOrder }})</option>
 | 
			
		||||
					<option value="+lastCommunicatedAt">{{ $ts.lastCommunication }} ({{ $ts.descendingOrder }})</option>
 | 
			
		||||
					<option value="-lastCommunicatedAt">{{ $ts.lastCommunication }} ({{ $ts.ascendingOrder }})</option>
 | 
			
		||||
					<option value="+driveUsage">{{ $ts.driveUsage }} ({{ $ts.descendingOrder }})</option>
 | 
			
		||||
					<option value="-driveUsage">{{ $ts.driveUsage }} ({{ $ts.ascendingOrder }})</option>
 | 
			
		||||
					<option value="+driveFiles">{{ $ts.driveFilesCount }} ({{ $ts.descendingOrder }})</option>
 | 
			
		||||
					<option value="-driveFiles">{{ $ts.driveFilesCount }} ({{ $ts.ascendingOrder }})</option>
 | 
			
		||||
				</MkSelect>
 | 
			
		||||
			</FormSplit>
 | 
			
		||||
		</div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue