-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
90 lines (68 loc) · 3.5 KB
/
Copy pathmodels.py
File metadata and controls
90 lines (68 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from sqlalchemy import Boolean, Column, DateTime, Float, ForeignKey, Integer, String, Text
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from database import Base
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
name = Column(String(100))
email = Column(String(255), unique=True, index=True)
password_hash = Column(String(255))
plan = Column(String(50), default="free")
email_verified = Column(Boolean, default=False, nullable=False)
email_verification_token = Column(String(255), nullable=True, index=True)
email_verification_sent_at = Column(DateTime(timezone=True), nullable=True)
password_reset_token = Column(String(255), nullable=True, index=True)
password_reset_sent_at = Column(DateTime(timezone=True), nullable=True)
marketing_opt_in = Column(Boolean, default=False, nullable=False)
marketing_opt_in_at = Column(DateTime(timezone=True), nullable=True)
github_id = Column(String(255), nullable=True, index=True)
github_username = Column(String(255), nullable=True)
auth_provider = Column(String(50), default="email")
paddle_customer_id = Column(String(255), nullable=True, index=True)
paddle_subscription_id = Column(String(255), nullable=True, index=True)
subscription_status = Column(String(50), nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
targets = relationship("Target", back_populates="user")
class Target(Base):
"""
A saved/tracked repository analysis.
This is the single source of truth for analyses, pipeline status, and
analytics. analytics.csv / targets.csv are no longer written to or read
from — everything lives here so it can be scoped per user.
"""
__tablename__ = "targets"
id = Column(Integer, primary_key=True)
# Nullable so anonymous (logged-out) free-tier analyses can still be
# recorded for rate limiting, but every pipeline entry created by a
# logged-in user always has user_id set, and dashboard/pipeline queries
# filter on it so accounts no longer share data.
user_id = Column(Integer, ForeignKey("users.id"), nullable=True, index=True)
repo = Column(String(255), index=True)
repo_url = Column(String(500))
language = Column(String(100))
score = Column(Float)
status = Column(String(50), default="New Target")
best_issue = Column(String(100))
best_issue_url = Column(String(500))
merge_probability = Column(String(100))
difficulty = Column(String(100))
estimated_time = Column(String(100))
pitch = Column(Text)
stars = Column(Integer, default=0)
forks = Column(Integer, default=0)
open_issues = Column(Integer, default=0)
# Used only for free-tier rate limiting of anonymous (logged-out) visitors.
ip_address = Column(String(64), index=True)
created_at = Column(DateTime(timezone=True), server_default=func.now(), index=True)
user = relationship("User", back_populates="targets")
class Event(Base):
__tablename__ = "events"
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=True, index=True)
event_name = Column(String(100), nullable=False, index=True)
page = Column(String(500), nullable=True)
referrer = Column(String(500), nullable=True)
user_agent = Column(String(500), nullable=True)
metadata_json = Column("metadata", Text, nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now(), index=True)