Files
perinco-CRM/server/src/scanner/models/Project.js
T
Sascha WolfandClaude Opus 5 af3ca33743 feat(scanner): Funde mit Akquise und Opportunities abgleichen
Neu gefundene Projekte mit Treffer werden einmalig per gpt-5.6-luna mit den
Akquise-Eintraegen und Opportunities der letzten N Tage (Vorgabe 14)
verglichen. Passt ein Eintrag, zeigt der Scanner "bereits beworben!" samt
Begruendung. Schalter und Zeitraum (Tage/Wochen) in Einstellungen -> Scanner,
Neupruefung von Hand im Detail.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 17:12:17 +02:00

92 lines
2.0 KiB
JavaScript

import { DataTypes } from 'sequelize';
import sequelize from '../db/config.js';
const Project = sequelize.define('Project', {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
},
portal: {
type: DataTypes.STRING(50),
allowNull: false,
},
portalProjectId: {
type: DataTypes.STRING(100),
allowNull: false,
field: 'portal_project_id',
},
title: {
type: DataTypes.STRING,
allowNull: false,
},
description: {
type: DataTypes.TEXT('long'),
allowNull: true,
},
company: {
type: DataTypes.STRING,
allowNull: true,
},
location: {
type: DataTypes.STRING,
allowNull: true,
},
rate: {
type: DataTypes.STRING(100),
allowNull: true,
},
url: {
type: DataTypes.STRING(500),
allowNull: false,
},
publishedAt: {
type: DataTypes.DATE,
allowNull: true,
field: 'published_at',
},
// Abgleich mit Akquise und Opportunities (services/appliedCheck.js). Die
// Spalten zieht initScannerDatabase() per ALTER TABLE nach.
alreadyApplied: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
field: 'already_applied',
},
appliedRefs: {
type: DataTypes.TEXT,
allowNull: true,
field: 'applied_refs',
comment: 'JSON array: [{ type, id, title, consultant, reason }]',
get() {
const rawValue = this.getDataValue('appliedRefs');
try {
return rawValue ? JSON.parse(rawValue) : [];
} catch {
return [];
}
},
set(value) {
this.setDataValue('appliedRefs', value ? JSON.stringify(value) : null);
},
},
appliedCheckAt: {
type: DataTypes.DATE,
allowNull: true,
field: 'applied_check_at',
},
}, {
tableName: 'projects',
indexes: [
{
unique: true,
fields: ['portal', 'portal_project_id'],
},
],
timestamps: true,
updatedAt: false, // projects are immutable once scraped, we only track when they were created
createdAt: 'created_at',
});
export default Project;