Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shail
smradius
Commits
3ead6c5a
Commit
3ead6c5a
authored
15 years ago
by
Robert Anderson
Browse files
Options
Downloads
Patches
Plain Diff
Update pre-existing summary records instead of recreating record
parent
99ff285f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smradius/modules/system/mod_config_sql_topups.pm
+45
-16
45 additions, 16 deletions
smradius/modules/system/mod_config_sql_topups.pm
with
45 additions
and
16 deletions
smradius/modules/system/mod_config_sql_topups.pm
+
45
−
16
View file @
3ead6c5a
...
...
@@ -784,9 +784,11 @@ sub cleanup
# Loop through summary topups
foreach
my
$summaryTopup
(
@summaryTopups
)
{
# Delete any previous record of this summary
$sth
=
DBDo
('
DELETE FROM
# Check if this record exists
my
$sth
=
DBSelect
('
SELECT
COUNT(*) as rowCount
FROM
@TP@topups_summary
WHERE
TopupID = ?
...
...
@@ -795,24 +797,51 @@ sub cleanup
);
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to
delete previous
record:
"
.
$server
->
log
(
LOG_ERR
,"
[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to
check for existing
record:
"
.
awitpt::db::dblayer::
Error
());
goto
FAIL_ROLLBACK
;
}
# Insert topup summary
$sth
=
DBDo
('
INSERT INTO
@TP@topups_summary (TopupID,PeriodKey,Balance)
VALUES
(?,?,?)
',
$summaryTopup
->
{'
ID
'},
$periodKey
,
$summaryTopup
->
{'
Balance
'}
my
$recordCheck
=
$sth
->
fetchrow_hashref
();
$recordCheck
=
hashifyLCtoMC
(
$recordCheck
,
qw(rowCount)
);
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to update topups_summary:
"
.
awitpt::db::dblayer::
Error
());
goto
FAIL_ROLLBACK
;
# Update topup summary
if
(
defined
(
$recordCheck
->
{'
rowCount
'})
&&
$recordCheck
->
{'
rowCount
'}
>
0
)
{
$sth
=
DBDo
('
UPDATE
@TP@topups_summary
SET
Balance = ?
WHERE
TopupID = ?
AND PeriodKey = ?
',
$summaryTopup
->
{'
Balance
'},
$summaryTopup
->
{'
ID
'},
$periodKey
);
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to delete previous record:
"
.
awitpt::db::dblayer::
Error
());
goto
FAIL_ROLLBACK
;
}
# Insert topup summary
}
else
{
$sth
=
DBDo
('
INSERT INTO
@TP@topups_summary (TopupID,PeriodKey,Balance)
VALUES
(?,?,?)
',
$summaryTopup
->
{'
ID
'},
$periodKey
,
$summaryTopup
->
{'
Balance
'}
);
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to update topups_summary:
"
.
awitpt::db::dblayer::
Error
());
goto
FAIL_ROLLBACK
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment