Skip to content

Commit

Permalink
fix: Make CSV output user friendly
Browse files Browse the repository at this point in the history
Drop unnecessary column: id
rename column totalcontributionTime -> totalSwipeTimeInSeconds
rename column totalcontributions -> totalSwipes
  • Loading branch information
bshankar committed Sep 24, 2024
1 parent 475b66a commit 302d623
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions backend/models/dtos/partner_stats_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ class GroupedPartnerStatsDTO(Model):

def to_csv(self):
df = pd.json_normalize(self.to_primitive()["members"])

df.drop(
columns=["id"],
inplace=True,
axis=1,
)
df.rename(
columns={
"totalcontributionTime": "totalSwipeTimeInSeconds",
"totalcontributions": "totalSwipes",
},
inplace=True,
)

return df.to_csv(index=False)


Expand Down

0 comments on commit 302d623

Please sign in to comment.