Skip to content

Commit

Permalink
Merge pull request #288 from ral-facilities/bugfix/study-pids-generat…
Browse files Browse the repository at this point in the history
…or-#287

Add Study PIDs to Generator Script
  • Loading branch information
MRichards99 authored Nov 15, 2021
2 parents 254249f + 89a9e27 commit a9a6d13
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions datagateway_api/common/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ class STUDY(Base, EntityHelper, metaclass=EntityMeta):
modId = Column("MOD_ID", String(255), nullable=False)
modTime = Column("MOD_TIME", DateTime, nullable=False)
name = Column("NAME", String(255), nullable=False)
pid = Column("PID", String(255))
startDate = Column("STARTDATE", DateTime)
status = Column("STATUS", Integer)
userID = Column("USER_ID", ForeignKey("USER_.ID"), index=True)
Expand Down
2 changes: 2 additions & 0 deletions datagateway_api/src/swagger/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,8 @@ components:
type: string
name:
type: string
pid:
type: string
startDate:
format: datetime
type: string
Expand Down
3 changes: 3 additions & 0 deletions util/icat_db_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ def generate_user_groups(i):
class StudyGenerator(Generator):
tier = 3
amount = UserGenerator.amount
pid_faker = Faker()
pid_faker.seed_instance(SEED)

def generate(self):
for i in range(1, self.amount):
Expand All @@ -434,6 +436,7 @@ def generate_studies(i):
apply_common_attributes(study, i)
study.startDate = get_start_date(i)
study.status = faker.random_int(0, 1)
study.pid = StudyGenerator.pid_faker.isbn10(separator="-")
study.userID = i
post_entity(study)

Expand Down

0 comments on commit a9a6d13

Please sign in to comment.