|
1 | | -# from datetime import datetime |
2 | | -# from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, func,BigInteger |
3 | | -# from sqlalchemy.orm import relationship |
4 | | -# from sqlalchemy.ext.declarative import declarative_base |
5 | | - |
6 | | - |
7 | | -# Base = declarative_base() |
8 | | - |
9 | | - |
10 | | - |
11 | | -# # Define your models |
12 | | -# class DmpIssue(Base): |
13 | | -# __tablename__ = 'dmp_issues' |
14 | | - |
15 | | -# id = Column(Integer, primary_key=True, autoincrement=True) |
16 | | -# issue_url = Column(String, nullable=False) |
17 | | -# issue_number = Column(Integer, nullable=False) |
18 | | -# mentor_username = Column(String, nullable=True) |
19 | | -# contributor_username = Column(String, nullable=True) |
20 | | -# title = Column(String, nullable=False) |
21 | | -# org_id = Column(Integer, ForeignKey('dmp_orgs.id'), nullable=False) |
22 | | -# description = Column(Text, nullable=True) |
23 | | -# repo = Column(String, nullable=True) |
24 | | - |
25 | | -# def __repr__(self): |
26 | | -# return f"<DmpIssue(id={self.id}, title={self.title})>" |
27 | | - |
28 | | -# def to_dict(self): |
29 | | -# return { |
30 | | -# 'id': self.id, |
31 | | -# 'issue_url': self.issue_url, |
32 | | -# 'issue_number': self.issue_number, |
33 | | -# 'mentor_username': self.mentor_username, |
34 | | -# 'contributor_username': self.contributor_username, |
35 | | -# 'title': self.title, |
36 | | -# 'org_id': self.org_id, |
37 | | -# 'description': self.description, |
38 | | -# 'repo': self.repo |
39 | | -# } |
40 | | - |
41 | | -# class DmpOrg(Base): |
42 | | -# __tablename__ = 'dmp_orgs' |
43 | | - |
44 | | -# id = Column(Integer, primary_key=True, autoincrement=True) |
45 | | -# created_at = Column(DateTime, default=datetime.utcnow, nullable=False) |
46 | | -# name = Column(String, nullable=False) |
47 | | -# description = Column(Text, nullable=True) |
48 | | -# link = Column(String, nullable=False) |
49 | | -# repo_owner = Column(String, nullable=False) |
50 | | -# dmp_issues = relationship('DmpIssue', backref='organization', lazy=True) |
51 | | - |
52 | | -# def __repr__(self): |
53 | | -# return f"<DmpOrg(id={self.id}, name={self.name})>" |
54 | | - |
55 | | -# def to_dict(self): |
56 | | -# return { |
57 | | -# 'id': self.id, |
58 | | -# 'created_at': self.created_at.isoformat(), |
59 | | -# 'name': self.name, |
60 | | -# 'description': self.description, |
61 | | -# 'link': self.link, |
62 | | -# 'repo_owner': self.repo_owner |
63 | | -# } |
64 | | - |
65 | | - |
66 | | -# class DmpIssueUpdate(Base): |
67 | | -# __tablename__ = 'dmp_issue_updates' |
68 | | - |
69 | | -# created_at = Column(DateTime, default=datetime.utcnow, nullable=False) |
70 | | -# body_text = Column(Text, nullable=False) |
71 | | -# comment_link = Column(String, nullable=False) |
72 | | -# comment_id = Column(BigInteger, primary_key=True, nullable=False) |
73 | | -# comment_api = Column(String, nullable=False) |
74 | | -# comment_updated_at = Column(DateTime, nullable=False) |
75 | | -# dmp_id = Column(Integer, ForeignKey('dmp_orgs.id'), nullable=False) |
76 | | -# created_by = Column(String, nullable=False) |
77 | | - |
78 | | -# def __repr__(self): |
79 | | -# return f"<DmpIssueUpdate(comment_id={self.comment_id}, dmp_id={self.dmp_id})>" |
80 | | - |
81 | | -# def to_dict(self): |
82 | | -# return { |
83 | | -# 'created_at': self.created_at.isoformat(), |
84 | | -# 'body_text': self.body_text, |
85 | | -# 'comment_link': self.comment_link, |
86 | | -# 'comment_id': self.comment_id, |
87 | | -# 'comment_api': self.comment_api, |
88 | | -# 'comment_updated_at': self.comment_updated_at.isoformat(), |
89 | | -# 'dmp_id': self.dmp_id, |
90 | | -# 'created_by': self.created_by |
91 | | -# } |
92 | | - |
93 | | -# class Prupdates(Base): |
94 | | -# __tablename__ = 'dmp_pr_updates' |
95 | | - |
96 | | -# created_at = Column(DateTime, nullable=False, default=datetime.utcnow) |
97 | | -# pr_id = Column(Integer, nullable=False, primary_key=True) |
98 | | -# status = Column(String, nullable=False) |
99 | | -# title = Column(String, nullable=False) |
100 | | -# pr_updated_at = Column(DateTime, nullable=False, default=datetime.utcnow) |
101 | | -# merged_at = Column(DateTime) |
102 | | -# closed_at = Column(DateTime) |
103 | | -# dmp_id = Column(Integer, ForeignKey('dmp_issues.id'), nullable=False) |
104 | | -# link = Column(String, nullable=False) |
105 | | - |
106 | | -# def __repr__(self): |
107 | | -# return f'<PullRequest {self.pr_id} - {self.title}>' |
108 | | - |
109 | | -# def to_dict(self): |
110 | | -# return { |
111 | | -# 'created_at': self.created_at.isoformat(), |
112 | | -# 'pr_id': self.pr_id, |
113 | | -# 'status': self.status, |
114 | | -# 'title': self.title, |
115 | | -# 'pr_updated_at': self.pr_updated_at.isoformat(), |
116 | | -# 'merged_at': self.merged_at.isoformat() if self.merged_at else None, |
117 | | -# 'closed_at': self.closed_at.isoformat() if self.closed_at else None, |
118 | | -# 'dmp_id': self.dmp_id, |
119 | | -# 'link': self.link |
120 | | -# } |
121 | | - |
122 | | -# class DmpWeekUpdate(Base): |
123 | | -# __tablename__ = 'dmp_week_updates' |
124 | | - |
125 | | -# id = Column(Integer, primary_key=True, autoincrement=True) |
126 | | -# issue_url = Column(String, nullable=False) |
127 | | -# week = Column(Integer, nullable=False) |
128 | | -# total_task = Column(Integer, nullable=False) |
129 | | -# completed_task = Column(Integer, nullable=False) |
130 | | -# progress = Column(Integer, nullable=False) |
131 | | -# task_data = Column(Text, nullable=False) |
132 | | -# dmp_id = Column(Integer, nullable=False) |
133 | | - |
134 | | -# def __repr__(self): |
135 | | -# return f"<DmpWeekUpdate(id={self.id}, week={self.week}, dmp_id={self.dmp_id})>" |
136 | | - |
137 | | -# def to_dict(self): |
138 | | -# return { |
139 | | -# 'id': self.id, |
140 | | -# 'week': self.week, |
141 | | -# 'dmp_id': self.dmp_id, |
142 | | -# } |
0 commit comments